Class: Dhall::Builtins::Natural_build

Inherits:
Dhall::Builtin show all
Defined in:
lib/dhall/builtins.rb

Instance Method Summary collapse

Methods inherited from Dhall::Builtin

#as_json, #unfill

Methods inherited from Expression

#&, #*, #+, #as_dhall, #cache_key, #concat, decode, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #merge, #normalize, #resolve, #shift, #slice, #substitute, #to_cbor, #to_proc, #to_s, #|

Instance Method Details

#call(arg) ⇒ Object



106
107
108
109
110
111
112
113
114
115
# File 'lib/dhall/builtins.rb', line 106

def call(arg)
	arg.call(
		Natural.new,
		Function.of_arguments(
			Natural.new,
			body: Variable["_"] + Dhall::Natural.new(value: 1)
		),
		Dhall::Natural.new(value: 0)
	)
end

#fusion(arg, *bogus) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/dhall/builtins.rb', line 96

def fusion(arg, *bogus)
	if bogus.empty? &&
	   arg.is_a?(Application) &&
	   arg.function == Natural_fold.new
		arg.argument
	else
		super
	end
end