Explorer

core.type-substitute

description
Replace the type parameters `parameter(name)` in the type with the types given by name in `arguments`
type
Fn(type: @core.type-ast, arguments: List<Record{name: String, type: @core.type-ast}>) -> @core.type-ast
expression
fn(type$0, arguments$1) =>
  match $0 {
    #parameter(name$2) =>
      match @core.function-type-parameter-find(parameters: $1, name: $2, index: 0) {
        #none(_) =>
          $0,
        #some(argument$3) =>
          $3
      },
    #list(list_type$4) =>
      #list({item_type: @core.type-substitute(type: $4.item_type, arguments: $1)}),
    #function(function_type$5) =>
      #function({
        parameters: @core.type-substitute-parameters(parameters: $5.parameters, arguments: $1, index: 0, accum: []),
        return_type: @core.type-substitute(type: $5.return_type, arguments: $1)
      }),
    #record(fields$6) =>
      #record(@core.type-substitute-fields(fields: $6, arguments: $1, index: 0, accum: [])),
    #union(variants$7) =>
      #union(@core.type-substitute-variants(variants: $7, arguments: $1, index: 0, accum: [])),
    #apply(apply_type$8) =>
      #apply({
        part_hash: $8.part_hash,
        arguments: @core.type-substitute-parameters(parameters: $8.arguments, arguments: $1, index: 0, accum: [])
      }),
    #code(code_type$9) =>
      #code(@core.type-substitute(type: $9, arguments: $1)),
    _ =>
      $0
  }
visibility
public
core.type-substitute (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: ATg-g4t7gDnqpZXz5ER1zujqLi7M3k3zKf_plyo1jcU
content hash: zGkFFn0ecIAFPcJwxuPlp2Vg5ioi2PmM0XkmjSmiRRE