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.



473
474
475
# File 'lib/dhall/typecheck.rb', line 473

def initialize(type)
	@type = type
end

Instance Method Details

#annotate(context) ⇒ Object



477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/dhall/typecheck.rb', line 477

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