Explorer

core.eval-native-value-to-parts

description
The parts {id, expression} of values (records with an id string and an expression value, read by core.value-to-expression), or none if one has another shape. For core.code-parts, and for core.compile-to-wasm run natively by core.eval-value
type
Fn(items: List<@core.value>) -> Union{#none, #some(List<Record{id: String, expression: @core.expression}>)}
expression
fn(items$0) =>
  @core.list-fold(
    T: @core.value,
    A: Union{#none, #some(List<Record{id: String, expression: @core.expression}>)},
    reducer: fn(acc$1, item$2) =>
      match $1 {
        #none(_) =>
          #none,
        #some(parts$3) =>
          match $2 {
            #record(fields$4) =>
              match @core.record-field-lookup(items: $4, key: "id", index: 0) {
                #string(id$5) =>
                  match @core.value-to-expression(value: @core.record-field-lookup(items: $4, key: "expression", index: 0)) {
                    #some(expression$6) =>
                      #some(@core.list-append(list: $3, item: {id: $5, expression: $6})),
                    #none(_) =>
                      #none
                  },
                _ =>
                  #none
              },
            _ =>
              #none
          }
      },
    init: #some([]),
    xs: $0
  )
visibility
public
core.eval-native-value-to-parts (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: ANf2nWWNILOw3WW9xmMvqALLXFH6X8DHa6p_BioSLhg
content hash: 7QDT8cNlGG-OE5DQX6MLQyRddSiLneDVFKn8XMS1JQg