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.



983
984
985
986
# File 'lib/dhall/typecheck.rb', line 983

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

Class Method Details

.for(letin) ⇒ Object



975
976
977
978
979
980
981
# File 'lib/dhall/typecheck.rb', line 975

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

Instance Method Details

#annotate(context) ⇒ Object



988
989
990
991
992
993
994
995
996
# File 'lib/dhall/typecheck.rb', line 988

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