Class: Dhall::LetIn

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

Instance Method Summary collapse

Methods inherited from Expression

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

Instance Method Details

#as_jsonObject



1514
1515
1516
# File 'lib/dhall/ast.rb', line 1514

def as_json
  [25, *let.as_json, body.as_json]
end

#desugarObject



1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
# File 'lib/dhall/ast.rb', line 1496

def desugar
  Application.new(
    function: Function.new(
      var:  let.var,
      type: let.type,
      body: body
    ),
    argument: let.assign
  )
end

#eliminateObject



1507
1508
1509
1510
1511
1512
# File 'lib/dhall/ast.rb', line 1507

def eliminate
  body.substitute(
    Dhall::Variable[let.var],
    let.assign.shift(1, let.var, 0)
  ).shift(-1, let.var, 0)
end

#normalizeObject



391
392
393
# File 'lib/dhall/normalize.rb', line 391

def normalize
  desugar.normalize
end

#shift(amount, name, min_index) ⇒ Object



395
396
397
398
399
400
401
402
# File 'lib/dhall/normalize.rb', line 395

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