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

Returns a new instance of Forall.



760
761
762
763
764
765
766
# File 'lib/dhall/typecheck.rb', line 760

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



801
802
803
804
805
806
807
808
809
# File 'lib/dhall/typecheck.rb', line 801

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