Class: Dhall::TypeChecker::List

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

Defined Under Namespace

Classes: AnnotatedList

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ List

Returns a new instance of List.



409
410
411
# File 'lib/dhall/typecheck.rb', line 409

def initialize(list)
	@list = list
end

Instance Method Details

#annotate(context) ⇒ Object



432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/dhall/typecheck.rb', line 432

def annotate(context)
	alist = AnnotatedList.new(@list.map(type: @list.element_type) { |el|
		TypeChecker.for(el).annotate(context)
	})

	TypeChecker.assert alist.element_types,
	                   Util::ArrayOf.new(alist.element_type),
	                   "Non-homogenous List"

	TypeChecker.assert_type alist.element_type, Builtins[:Type],
	                        "List type not of type Type", context: context

	alist.annotation
end