class Dhall::Application
Public Class Methods
decode(function, *args)
click to toggle source
# File lib/dhall/binary.rb, line 54 def self.decode(function, *args) function = Dhall.decode(function) args.map(&Dhall.method(:decode)).reduce(function) do |f, arg| self.for(function: f, argument: arg) end end
for(function:, argument:)
click to toggle source
# File lib/dhall/ast.rb, line 126 def self.for(function:, argument:) if function == Builtins[:None] OptionalNone.new(value_type: argument) else new(function: function, argument: argument) end end
Public Instance Methods
as_json()
click to toggle source
# File lib/dhall/ast.rb, line 147 def as_json function, arguments = flatten [0, function.as_json, *arguments.map(&:as_json)] end
flatten()
click to toggle source
# File lib/dhall/ast.rb, line 134 def flatten f, args = if function.is_a?(Application) function.flatten elsif function.is_a?(BuiltinFunction) && (unfilled = function.unfill).is_a?(Application) unfilled.flatten else [function, []] end [f, args + [argument]] end
fuse()
click to toggle source
# File lib/dhall/normalize.rb, line 74 def fuse if function.is_a?(Application) @fuse ||= function.function.fusion(function.argument, argument) return @fuse if @fuse end @fuse ||= function.fusion(argument) end
normalize()
click to toggle source
Calls superclass method
Dhall::Expression#normalize
# File lib/dhall/normalize.rb, line 59 def normalize return fuse.normalize if fuse normalized = super return normalized.fuse if normalized.fuse if normalized.function.is_a?(BuiltinFunction) || normalized.function.is_a?(Function) || normalized.function.is_a?(RecordSelection) return normalized.function.call(normalized.argument) end normalized end