Class: Dhall::TypeChecker::EmptyList

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

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ EmptyList

Returns a new instance of EmptyList.



387
388
389
# File 'lib/dhall/typecheck.rb', line 387

def initialize(expr)
	@expr = expr.with(type: expr.type.normalize)
end

Instance Method Details

#annotate(context) ⇒ Object



391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/dhall/typecheck.rb', line 391

def annotate(context)
	TypeChecker.assert @expr.type, Dhall::Application,
	                   "EmptyList unknown type #{@expr.type.inspect}"

	TypeChecker.assert @expr.type.function, Builtins[:List],
	                   "EmptyList unknown type #{@expr.type.inspect}"

	TypeChecker.assert_type @expr.element_type, Builtins[:Type],
	                        "EmptyList element type not of type Type",
	                        context: context

	Dhall::TypeAnnotation.new(type: @expr.type, value: @expr)
end