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.



985
986
987
# File 'lib/dhall/typecheck.rb', line 985

def initialize(expr)
	@expr = expr
end

Instance Method Details

#annotate(context) ⇒ Object



989
990
991
992
993
994
995
996
997
998
# File 'lib/dhall/typecheck.rb', line 989

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