Class: Dhall::TypeChecker::LetIn

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

Direct Known Subclasses

LetInAnnotated

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letin) ⇒ LetIn

Returns a new instance of LetIn.



882
883
884
885
# File 'lib/dhall/typecheck.rb', line 882

def initialize(letin)
  @letin = letin
  @let = @letin.let
end

Class Method Details

.for(letin) ⇒ Object



874
875
876
877
878
879
880
# File 'lib/dhall/typecheck.rb', line 874

def self.for(letin)
  if letin.let.type
    LetInAnnotated.new(letin)
  else
    LetIn.new(letin)
  end
end

Instance Method Details

#annotate(context) ⇒ Object



887
888
889
890
891
892
893
894
895
# File 'lib/dhall/typecheck.rb', line 887

def annotate(context)
  alet = @let.with(type: assign_type(context))
  type = TypeChecker.for(@letin.eliminate).annotate(context).type
  abody = Dhall::TypeAnnotation.new(value: @letin.body, type: type)
  Dhall::TypeAnnotation.new(
    value: @letin.with(let: alet, body: abody),
    type:  type
  )
end