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.



895
896
897
# File 'lib/dhall/typecheck.rb', line 895

def initialize(expr)
  @expr = expr
end

Instance Method Details

#annotate(context) ⇒ Object



899
900
901
902
903
904
905
906
907
908
# File 'lib/dhall/typecheck.rb', line 899

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