Explorer

definy.check-snapshot-input

description
Check a project snapshot read by the host (definy.snapshot-check-input) and pass the reasons to reject it to then (empty if none). In order: the parts whose content is not a core.part-content, references to parts it cannot reference (core.check-reference-visibility, docs/visibility.md), and the type checker (core.type-checker decides the type environment and what to check, and each part is checked with its check: definy.type-check-requests-errors)
type
Fn(input: @definy.snapshot-check-input, then: Fn(errors: List<String>) -> @definy.service-io) -> @definy.service-io
expression
fn(input$0, then$1) =>
  let malformed$2 = @definy.snapshot-check-malformed(parts: $0.parts);
  match @core.list-get(list: $2, index: 0) {
    #some(_) =>
      $1(errors: $2),
    #none(_) =>
      let violations$3 = @core.check-reference-visibility(
          project_name: $0.project_name,
          committed: @definy.snapshot-check-visibility-parts(parts: $0.parts),
          environment: $0.environment
        );
      match @core.list-get(list: $3, index: 0) {
        #some(_) =>
          $1(
            errors: @core.list-map(
              T: @core.visibility-violation,
              U: String,
              f: fn(item$4) =>
                @definy.visibility-violation-message(violation: $4),
              xs: $3
            )
          ),
        #none(_) =>
          let latest$6 = @definy.snapshot-check-latest-entries(
              latest: $0.latest,
              replaced: @core.list-concat(
                left: @core.list-map(
                  T: @definy.snapshot-check-part,
                  U: String,
                  f: fn(item$5) =>
                    $5.module_id,
                  xs: $0.parts
                ),
                right: $0.project_module_ids
              )
            );
          let committed$7 = @definy.snapshot-check-entries(parts: $0.parts, resolutions: $0.resolutions);
          let plan$8 = @core.type-checker(latest: $6, committed: $7, module_id: "#replaced");
          let without_expression$9 = @definy.snapshot-check-without-expression(ids: $8.without_expression, parts: $0.parts);
          $1(
            errors: @core.list-concat(
              left: $9,
              right: @definy.type-check-requests-errors(
                requests: @definy.snapshot-check-requests(ids: $8.to_check, parts: $0.parts),
                check: fn(expr$10, expected_type$11) =>
                  $8.check(expr: $10, expected_type: $11)
              )
            )
          )
      }
  }
visibility
public
definy.check-snapshot-input (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: KDRSJxuo-5HDaK5Zf9IYilX8uhykLkU_v343wsRZ9KQ
content hash: kCGVEF8pJtMx1dhjvLU3k1Eyyli8IW94tPey0hLWaJ0