Class: Dhall::TypeChecker::TypeAnnotation

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

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ TypeAnnotation

Returns a new instance of TypeAnnotation.



1021
1022
1023
# File 'lib/dhall/typecheck.rb', line 1021

def initialize(expr)
	@expr = expr
end

Instance Method Details

#annotate(context) ⇒ Object



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
# File 'lib/dhall/typecheck.rb', line 1025

def annotate(context)
	redo_annotation = TypeChecker.for(@expr.value).annotate(context)

	if redo_annotation.type.normalize == @expr.type.normalize
		redo_annotation
	else
		raise TypeError, "TypeAnnotation does not match: " \
		                 "#{@expr.type}, #{redo_annotation.type}"
	end
end