class Dhall::Expression
Public Class Methods
decode(*args)
click to toggle source
# File lib/dhall/binary.rb, line 25 def self.decode(*args) return new(value: args.first) if args.length == 1 new(*args) end
Public Instance Methods
&(other)
click to toggle source
# File lib/dhall/ast.rb, line 50 def &(other) if self == other self elsif other.is_a?(Bool) other & self else Operator::And.new(lhs: self, rhs: other) end end
*(other)
click to toggle source
# File lib/dhall/ast.rb, line 38 def *(other) if other.is_a?(Natural) && other.zero? other * self else Operator::Times.new(lhs: self, rhs: other) end end
+(other)
click to toggle source
# File lib/dhall/ast.rb, line 34 def +(other) Operator::Plus.new(lhs: self, rhs: other) end
annotate(type)
click to toggle source
# File lib/dhall/ast.rb, line 107 def annotate(type) TypeAnnotation.new(value: self, type: type) end
as_dhall()
click to toggle source
# File lib/dhall/ast.rb, line 115 def as_dhall self end
cache_key()
click to toggle source
# File lib/dhall/binary.rb, line 48 def cache_key "sha256:#{digest.hexdigest}" end
call(*args)
click to toggle source
# File lib/dhall/ast.rb, line 16 def call(*args) args.reduce(self) { |f, arg| Application.new(function: f, argument: arg) }.normalize end
concat(other)
click to toggle source
# File lib/dhall/ast.rb, line 46 def concat(other) Operator::ListConcatenate.new(lhs: self, rhs: other) end
deep_merge(other)
click to toggle source
# File lib/dhall/ast.rb, line 80 def deep_merge(other) case other when EmptyRecord other.deep_merge(self) else Operator::RecursiveRecordMerge.new(lhs: self, rhs: other) end end
deep_merge_type(other)
click to toggle source
# File lib/dhall/ast.rb, line 98 def deep_merge_type(other) case other when EmptyRecordType other.deep_merge_type(self) else Operator::RecursiveRecordTypeMerge.new(lhs: self, rhs: other) end end
dhall_eq(other)
click to toggle source
# File lib/dhall/ast.rb, line 70 def dhall_eq(other) if self == other Bool.new(value: true) elsif other == Bool.new(value: true) other.dhall_eq(self) else Operator::Equal.new(lhs: self, rhs: other) end end
digest(digest: Digest::SHA2.new(256))
click to toggle source
# File lib/dhall/binary.rb, line 44 def digest(digest: Digest::SHA2.new(256)) (digest << normalize.to_cbor).freeze end
fetch(k)
click to toggle source
# File lib/dhall/ast.rb, line 26 def fetch(k) RecordSelection.new(record: self, selector: k) end
fusion(*)
click to toggle source
# File lib/dhall/normalize.rb, line 55 def fusion(*); end
merge(other)
click to toggle source
# File lib/dhall/ast.rb, line 89 def merge(other) case other when EmptyRecord other.merge(self) else Operator::RightBiasedRecordMerge.new(lhs: self, rhs: other) end end
normalize()
click to toggle source
# File lib/dhall/normalize.rb, line 39 def normalize with(ExpressionVisitor.new(&:normalize).visit(self)) end
resolve( resolver: Resolvers::Default.new, relative_to: Import::Path.from_string(Pathname.pwd + "file") )
click to toggle source
# File lib/dhall/resolve.rb, line 523 def resolve( resolver: Resolvers::Default.new, relative_to: Import::Path.from_string(Pathname.pwd + "file") ) p = ExpressionResolver.for(self).resolve( resolver: resolver, relative_to: relative_to ) resolver.finish! p end
shift(amount, name, min_index)
click to toggle source
# File lib/dhall/normalize.rb, line 43 def shift(amount, name, min_index) with(ExpressionVisitor.new { |expr| expr.shift(amount, name, min_index) }.visit(self)) end
slice(*keys)
click to toggle source
# File lib/dhall/ast.rb, line 30 def slice(*keys) RecordProjection.new(record: self, selectors: keys) end
substitute(var, with_expr)
click to toggle source
# File lib/dhall/normalize.rb, line 49 def substitute(var, with_expr) with(ExpressionVisitor.new { |expr| expr.substitute(var, with_expr) }.visit(self)) end
to_binary()
click to toggle source
# File lib/dhall/binary.rb, line 40 def to_binary CBOR.encode(::CBOR::Tagged.new(55799, self)) end
to_cbor(packer=nil)
click to toggle source
# File lib/dhall/binary.rb, line 31 def to_cbor(packer=nil) if packer packer.write(as_json) packer else CBOR.encode(as_json) end end
to_proc()
click to toggle source
# File lib/dhall/ast.rb, line 22 def to_proc method(:call).to_proc end
to_s()
click to toggle source
# File lib/dhall/ast.rb, line 111 def to_s inspect end
|(other)
click to toggle source
# File lib/dhall/ast.rb, line 60 def |(other) if self == other self elsif other.is_a?(Bool) other | self else Operator::Or.new(lhs: self, rhs: other) end end