Class: Dhall::TypeChecker::TypeAnnotation

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

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ TypeAnnotation



920
921
922
# File 'lib/dhall/typecheck.rb', line 920

def initialize(expr)
  @expr = expr
end

Instance Method Details

#annotate(context) ⇒ Object



924
925
926
927
928
929
930
931
932
933
# File 'lib/dhall/typecheck.rb', line 924

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