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.



483
484
485
# File 'lib/dhall/typecheck.rb', line 483

def initialize(type)
	@type = type
end

Instance Method Details

#annotate(context) ⇒ Object



487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/dhall/typecheck.rb', line 487

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