Explorer

core.compile-fold-constant-parts

description
The parts with each constant part (core.compile-time-constant-candidate) replaced by the literal of its value, computed at compile time by core.eval-value with these parts (core.value-literal). A part whose value is not a literal (a function, a float, a long list) or cannot be computed stays as it is. See docs/compile-time-evaluation.md
type
Fn(parts: List<Record{id: String, expression: @core.expression}>) -> List<Record{id: String, expression: @core.expression}>
expression
fn(parts$0) =>
  let index$5 = @core.list-hash-index(list: $0, field: "id");
  @core.list-map(
    T: Record{id: String, expression: @core.expression},
    U: Record{id: String, expression: @core.expression},
    f: fn(item$1) =>
      match @core.compile-time-constant-candidate(expr: $1.expression, index: $5) {
        false =>
          $1,
        true =>
          match @core.value-literal(value: @core.eval-value(expr: $1.expression, env: [], parts: $0)) {
            #some(literal$2) =>
              {id: $1.id, expression: $2},
            #none(_) =>
              $1
          }
      },
    xs: $0
  )
visibility
public
core.compile-fold-constant-parts (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: C7-kO5VzEtXnuAkmJgRGuMMPpAEGu3OBM6-A1FXLRq8
content hash: mac9VJ_yULU8n0RXLWMoKbIIKjjiv8Xbskjb8ffLwys