Class: Dhall::TypeChecker::OperatorEquivalent

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

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ OperatorEquivalent

Returns a new instance of OperatorEquivalent.



245
246
247
248
249
# File 'lib/dhall/typecheck.rb', line 245

def initialize(expr)
	@expr = expr
	@lhs = expr.lhs
	@rhs = expr.rhs
end

Instance Method Details

#annotate(context) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/dhall/typecheck.rb', line 251

def annotate(context)
	type = TypeChecker.assert_types_match @lhs, @rhs,
	                                      "arguments do not match",
	                                      context: context

	TypeChecker.assert_type type, Builtins[:Type],
	                        "arguments are not terms",
	                        context: context

	Dhall::TypeAnnotation.new(
		value: @expr.with(lhs: @lhs.annotate(type), rhs: @rhs.annotate(type)),
		type:  Builtins[:Type]
	)
end