Explorer

core.record-type-field-arguments

description
(en) For a record literal checked against a record type: the fields of type Type and the types written in the literal for them, so that Param("<field name>") in the types of the other fields means that type (a record that carries a type, used for the existential type of definy.io's all and race. docs/structured-concurrency.md). A field whose value is not a type expression (such as payload.Child) is left out, and the Param stays an opaque type
type
Fn(
  fields: List<Record{key: String, value: @core.expression}>,
  env: @core.type-env,
  expected_fields: List<Record{key: String, field_type: @core.type-ast}>
) -> List<Record{name: String, type: @core.type-ast}>
expression
fn(fields$0, env$1, expected_fields$2) =>
  @core.list-fold(
    T: Record{key: String, field_type: @core.type-ast},
    A: List<Record{name: String, type: @core.type-ast}>,
    reducer: fn(acc$3, item$4) =>
      match @core.type-equals(t1: $4.field_type, t2: #type) {
        false =>
          $3,
        true =>
          match @core.record-literal-find(fields: $0, key: $4.key, index: 0) {
            #none(_) =>
              $3,
            #some(value$5) =>
              match @core.type-expression-to-type-ast(expr: $5, parameters: $1.type_parameters) {
                #none(_) =>
                  $3,
                #some(type$6) =>
                  @core.list-append(list: $3, item: {name: $4.key, type: $6})
              }
          }
      },
    init: [],
    xs: $2
  )
visibility
public
core.record-type-field-arguments (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: oEi2cCqv6tGgyEmt6PFVJLO4dj9M-30esYDnOHRd7g4
content hash: tQnkKF69kVaL5QOQNmh71eisknP6TR87asHsBK2EX-g