Class: Dhall::TypeChecker::Application

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Application

Returns a new instance of Application.



840
841
842
843
844
# File 'lib/dhall/typecheck.rb', line 840

def initialize(app)
  @app = app
  @func = TypeChecker.for(app.function)
  @arg = app.argument
end

Instance Method Details

#annotate(context) ⇒ Object



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
# File 'lib/dhall/typecheck.rb', line 846

def annotate(context)
  afunc = @func.annotate(context)

  TypeChecker.assert afunc.type, Dhall::Forall,
                     "Application LHS is not a function"

  aarg = TypeChecker.for(
    Dhall::TypeAnnotation.new(value: @arg, type: afunc.type.type)
  ).annotate(context)

  Dhall::TypeAnnotation.new(
    value: @app.with(function: afunc, argument: aarg),
    type:  afunc.type.call(aarg.value)
  )
end