Class: Dhall::TypeChecker::OperatorListConcatenate

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/typecheck.rb

Defined Under Namespace

Modules: IsList

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ OperatorListConcatenate

Returns a new instance of OperatorListConcatenate.



270
271
272
273
274
# File 'lib/dhall/typecheck.rb', line 270

def initialize(expr)
	@expr = expr
	@lhs = TypeChecker.for(expr.lhs)
	@rhs = TypeChecker.for(expr.rhs)
end

Instance Method Details

#annotate(context) ⇒ Object



283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/dhall/typecheck.rb', line 283

def annotate(context)
	annotated_lhs = @lhs.annotate(context)
	annotated_rhs = @rhs.annotate(context)

	types = [annotated_lhs.type, annotated_rhs.type]
	assertion = Util::ArrayOf.new(Util::AllOf.new(IsList, types.first))
	TypeChecker.assert types, assertion,
	                   "Operator arguments wrong: #{types}"

	Dhall::TypeAnnotation.new(
		value: @expr.with(lhs: annotated_lhs, rhs: annotated_rhs),
		type:  types.first
	)
end