Class: Dhall::TypeChecker::AnonymousType

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

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ AnonymousType

Returns a new instance of AnonymousType.



498
499
500
# File 'lib/dhall/typecheck.rb', line 498

def initialize(type)
  @type = type
end

Instance Method Details

#annotate(context) ⇒ Object



502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/dhall/typecheck.rb', line 502

def annotate(context)
  kinds = @type.record.values.compact.map do |mtype|
    TypeChecker.for(mtype).annotate(context).type
  end

  TypeChecker.assert (kinds - KINDS), [],
                     "AnonymousType field kind not one of #{KINDS}"

  TypeChecker.assert kinds, Util::ArrayAllTheSame,
                     "AnonymousType field kinds not all the same"

  type = kinds.first || KINDS.first
  Dhall::TypeAnnotation.new(value: @type, type: type)
end