~singpolyma/dhall-ruby

6cf1a813675829195348683aeb8c602011784789 — Stephen Paul Weber 3 years ago b561310
Add new useful facilities to Function
1 files changed, 25 insertions(+), 1 deletions(-)

M lib/dhall/ast.rb
M lib/dhall/ast.rb => lib/dhall/ast.rb +25 -1
@@ 157,7 157,8 @@ module Dhall
			end
		end

		def call(*args)
		def call(*args, &block)
			args += [block] if block
			args.map! { |arg| arg&.as_dhall }
			return super if args.length > 1



@@ 168,6 169,29 @@ module Dhall
		end

		alias [] call
		alias === call

		def <<(other)
			FunctionProxy.new(
				->(*args, &block) { call(other.call(*args, &block)) },
				curry: false
			)
		end

		def >>(other)
			FunctionProxy.new(
				->(*args, &block) { other.call(call(*args, &block)) },
				curry: false
			)
		end

		def binding
			to_proc.binding
		end

		def curry
			self
		end

		def as_json
			if var == "_"