class Dhall::LetIn
Public Class Methods
decode(*parts)
click to toggle source
# File lib/dhall/binary.rb, line 278 def self.decode(*parts) body = Dhall.decode(parts.pop) parts.each_slice(3).map { |(var, type, assign)| Let.new( var: var, assign: Dhall.decode(assign), type: type.nil? ? nil : Dhall.decode(type) ) }.reverse.reduce(body) do |inside, let| LetIn.new(let: let, body: inside) end end
Public Instance Methods
as_json()
click to toggle source
# File lib/dhall/ast.rb, line 1818 def as_json flatten.as_json end
desugar()
click to toggle source
# File lib/dhall/ast.rb, line 1800 def desugar Application.new( function: Function.new( var: let.var, type: let.type, body: body ), argument: let.assign ) end
eliminate()
click to toggle source
# File lib/dhall/ast.rb, line 1811 def eliminate body.substitute( Dhall::Variable[let.var], let.assign.shift(1, let.var, 0) ).shift(-1, let.var, 0) end
flatten()
click to toggle source
# File lib/dhall/ast.rb, line 1791 def flatten flattened = body.is_a?(LetIn) ? body.flatten : body if flattened.is_a?(LetBlock) LetBlock.new(lets: lets + flattened.lets, body: flattened.body) else LetBlock.new(lets: lets, body: body) end end
lets()
click to toggle source
# File lib/dhall/ast.rb, line 1787 def lets [let] end
normalize()
click to toggle source
# File lib/dhall/normalize.rb, line 435 def normalize desugar.normalize end
shift(amount, name, min_index)
click to toggle source
Calls superclass method
Dhall::Expression#shift
# File lib/dhall/normalize.rb, line 439 def shift(amount, name, min_index) return super unless let.var == name with( let: let.shift(amount, name, min_index), body: body.shift(amount, name, min_index + 1) ) end
substitute(svar, with_expr)
click to toggle source
# File lib/dhall/normalize.rb, line 448 def substitute(svar, with_expr) var = let.var with( let: let.substitute(svar, with_expr), body: body.substitute( var == svar.name ? svar.with(index: svar.index + 1) : svar, with_expr.shift(1, var, 0) ) ) end