Class: Dhall::TypeChecker::Function

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

Instance Method Summary collapse

Constructor Details

#initialize(func) ⇒ Function

Returns a new instance of Function.



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

def initialize(func)
  @func = func
  @type = Dhall::Forall.new(
    var:  func.var,
    type: func.type,
    body: Dhall::Variable["UNKNOWN"]
  )
  @output = TypeChecker.for(func.body)
end

Instance Method Details

#annotate(context) ⇒ Object



934
935
936
937
938
939
940
941
942
943
# File 'lib/dhall/typecheck.rb', line 934

def annotate(context)
  abody = @output.annotate(context.add(@type))

  Dhall::TypeAnnotation.new(
    value: @func.with(body: abody),
    type:  TypeChecker.for(
      @type.with(body: abody.type)
    ).annotate(context).value
  )
end