Class: Dhall::Operator::Plus

Inherits:
Dhall::Operator show all
Defined in:
lib/dhall/ast.rb,
lib/dhall/normalize.rb

Constant Summary

Constants inherited from Dhall::Operator

OPERATORS

Instance Method Summary collapse

Methods inherited from Dhall::Operator

#as_json, decode

Methods inherited from Expression

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

Instance Method Details

#normalizeObject



197
198
199
200
201
202
203
204
205
206
# File 'lib/dhall/normalize.rb', line 197

def normalize
	normalized = super
	if normalized.lhs == Natural.new(value: 0)
		normalized.rhs
	elsif normalized.rhs == Natural.new(value: 0)
		normalized.lhs
	else
		normalized.lhs + normalized.rhs
	end
end