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.



914
915
916
# File 'lib/dhall/typecheck.rb', line 914

def initialize(expr)
	@expr = expr
end

Instance Method Details

#annotate(context) ⇒ Object



918
919
920
921
922
923
924
925
926
927
# File 'lib/dhall/typecheck.rb', line 918

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