Class: Dhall::TypeChecker::Builtin

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builtin) ⇒ Builtin

Returns a new instance of Builtin.



1292
1293
1294
1295
# File 'lib/dhall/typecheck.rb', line 1292

def initialize(builtin)
	@expr = builtin
	@name = builtin.as_json
end

Class Method Details

.for(builtin) ⇒ Object



1282
1283
1284
1285
1286
1287
1288
1289
1290
# File 'lib/dhall/typecheck.rb', line 1282

def self.for(builtin)
	if builtin.is_a?(Dhall::BuiltinFunction)
		if (unfilled = builtin.unfill) != builtin
			return TypeChecker.for(unfilled)
		end
	end

	new(builtin)
end

Instance Method Details

#annotateObject



1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/dhall/typecheck.rb', line 1297

def annotate(*)
	Dhall::TypeAnnotation.new(
		value: @expr,
		type:  BUILTIN_TYPES.fetch(@name) do
			raise TypeError, "Unknown Builtin #{@name}"
		end
	)
end