Explorer

core.quote-parts

description
The definitions {id, expression} of the parts with the ids as one string: core.encode-value of the list of records (the expression by core.expression-to-value). core.code-parts reads it back. An id without a part in parts is left out. One string, so a compiled quote holds the definitions as string data and not as instructions that build them
type
Fn(ids: List<String>, parts: List<Record{id: String, expression: @core.expression}>) -> String
expression
fn(ids$0, parts$1) =>
  let index$2 = @core.list-hash-index(list: $1, field: "id");
  @core.encode-value(
    value: #list<@core.value>(@core.list-fold(
      T: String,
      A: List<@core.value>,
      reducer: fn(acc$3, item$4) =>
        match @core.list-hash-index-find(index: $2, field: "id", value: $4) {
          #some(part$5) =>
            @core.list-append(
              list: $3,
              item: #record<@core.value>([
                {key: "id", value: #string<@core.value>($4)},
                {key: "expression", value: @core.expression-to-value(value: $5.expression)}
              ])
            ),
          #none(_) =>
            $3
        },
      init: [],
      xs: $0
    ))
  )
visibility
public
core.quote-parts (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: JQ3WlSS3zbndS405jN9QGMT8OMl2uP7HGsr-UdIA450
content hash: wHm5SktPWwa4JyiCY8LTnBhneYM5d2EUjpdDpm70gro