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.



815
816
817
818
819
820
821
822
823
# File 'lib/dhall/typecheck.rb', line 815

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



825
826
827
828
829
830
831
832
833
834
# File 'lib/dhall/typecheck.rb', line 825

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