Class: Dhall::TypeChecker::Forall

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

Defined Under Namespace

Modules: FunctionKind

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ Forall



741
742
743
744
745
746
747
# File 'lib/dhall/typecheck.rb', line 741

def initialize(expr)
  @expr = expr
  @var = expr.var
  @var_type = expr.type
  @input = TypeChecker.for(expr.type)
  @output = TypeChecker.for(expr.body)
end

Instance Method Details

#annotate(context) ⇒ Object



782
783
784
785
786
787
788
789
790
# File 'lib/dhall/typecheck.rb', line 782

def annotate(context)
  inkind = KINDS.index(@input.annotate(context).type)
  outkind = KINDS.index(@output.annotate(context.add(@expr)).type)

  Dhall::TypeAnnotation.new(
    value: @expr,
    type:  FunctionKind.for(inkind, outkind).kind
  )
end