Explorer

definy.latest-closure

description
Collect the candidates that the IDs of frontier reference, following the types of the parts found (definy.closure-entry-references with types_only), reading their resolutions and definitions level by level. none if a part found needs the evaluator (then the whole latest snapshots are used: definy.read-snapshot-check-input-full)
type
Fn(
  candidates: List<List<Record{id: String, candidate: @definy.closure-candidate}>>,
  frontier: List<String>,
  selected: List<String>,
  found: List<@definy.closure-candidate>,
  resolutions: List<@definy.resolution-cache-entry>,
  definitions: List<@definy.definition-cache-entry>,
  then: Fn(closure: Union{#none, #some(@definy.latest-closure-result)}) -> @definy.service-io
) -> @definy.service-io
expression
fn(candidates$0, frontier$1, selected$2, found$3, resolutions$4, definitions$5, then$6) =>
  let fresh$7 = @definy.closure-new-ids(ids: $1, selected: $2);
  let parts$8 = @definy.closure-find-all(candidates: $0, ids: $7);
  match @core.equal(left: @core.list-length(value: $8), right: 0) {
    true =>
      $6(closure: #some({parts: $3, resolutions: $4, definitions: $5})),
    false =>
      let hashes$9 = @core.list-map(
          T: @definy.closure-candidate,
          U: String,
          f: fn(item$10) =>
            $10.part.content_hash,
          xs: $8
        );
      @definy.read-resolutions(
        content_hashes: $9,
        then: fn(resolutions$11) =>
          @definy.read-definitions(
            content_hashes: @definy.unresolved-hashes(hashes: $9, resolutions: $11),
            then: fn(definitions$12) =>
              match @definy.closure-references(
                  parts: @core.list-map(
                    T: @definy.closure-candidate,
                    U: @definy.stored-snapshot-part,
                    f: fn(item$13) =>
                      $13.part,
                    xs: $8
                  ),
                  resolutions: $11,
                  definitions: $12,
                  types_only: true
                ) {
                #fallback(_) =>
                  $6(closure: #none),
                #refs(refs$14) =>
                  @definy.latest-closure(
                    candidates: $0,
                    frontier: $14,
                    selected: @core.list-concat(left: $2, right: $7),
                    found: @core.list-concat(left: $3, right: $8),
                    resolutions: @core.list-concat(left: $4, right: $11),
                    definitions: @core.list-concat(left: $5, right: $12),
                    then: fn(closure$15) =>
                      $6(closure: $15)
                  )
              }
          )
      )
  }
visibility
public
definy.latest-closure (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: Lsy8wBQ1hzpxDDf9Hx9Yz68WD4iLQ2P74chNzDqSfZg
content hash: giAhBJMgUsH81Ij1VTbHT9fnYe8AltBeNkxgkN7SRy8