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.



376
377
378
# File 'lib/dhall/typecheck.rb', line 376

def initialize(list)
  @list = list
end

Instance Method Details

#annotate(context) ⇒ Object



399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/dhall/typecheck.rb', line 399

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