Class: Dhall::TypeChecker::Optional

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

Instance Method Summary collapse

Constructor Details

#initialize(some) ⇒ Optional

Returns a new instance of Optional.



469
470
471
# File 'lib/dhall/typecheck.rb', line 469

def initialize(some)
	@some = some
end

Instance Method Details

#annotate(context) ⇒ Object



473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/dhall/typecheck.rb', line 473

def annotate(context)
	asome = @some.map do |el|
		TypeChecker.for(el).annotate(context)
	end
	some = asome.with(value_type: asome.value.type)

	type_type = TypeChecker.for(some.value_type).annotate(context).type
	TypeChecker.assert type_type, Builtins[:Type],
	                   "Some type not of type Type, was: #{type_type}"

	Dhall::TypeAnnotation.new(type: some.type, value: some)
end