Explorer

definy.merge-modules

description
The modules after a merge: the description and visibility are merged three-way like the parts, and each module gets its merged parts. A module without both is dropped
type
Fn(
  base: List<@core.project-snapshot-module>,
  ours: List<@core.project-snapshot-module>,
  theirs: List<@core.project-snapshot-module>,
  parts: List<@definy.merge-flat-part>
) -> List<@core.project-snapshot-module>
expression
fn(base$0, ours$1, theirs$2, parts$3) =>
  @core.list-fold(
    T: String,
    A: List<@core.project-snapshot-module>,
    reducer: fn(acc$4, item$5) =>
      let b$6 = @definy.merge-module-meta(modules: $0, name: $5);
      let o$7 = @definy.merge-module-meta(modules: $1, name: $5);
      let t$8 = @definy.merge-module-meta(modules: $2, name: $5);
      let chosen$9 = match @core.or(left: @core.equal(left: $7, right: $8), right: @core.equal(left: $8, right: $6)) {
          true =>
            $7,
          false =>
            $8
        };
      let module_parts$10 = @core.list-fold(
          T: @definy.merge-flat-part,
          A: List<@core.module-snapshot-part>,
          reducer: fn(acc$11, item$12) =>
            match @core.equal(left: $12.module, right: $5) {
              true =>
                @core.list-append(list: $11, item: {name: $12.name, content_hash: $12.content_hash}),
              false =>
                $11
            },
          init: [],
          xs: $3
        );
      let meta$13 = match $9 {
          #some(_) =>
            $9,
          #none(_) =>
            match @core.equal(left: @core.list-length(value: $10), right: 0) {
              true =>
                $9,
              false =>
                match $7 {
                  #some(_) =>
                    $7,
                  #none(_) =>
                    $8
                }
            }
        };
      match $13 {
        #none(_) =>
          $4,
        #some(meta$14) =>
          @core.list-append(list: $4, item: {name: $5, description: $14.description, visibility: $14.visibility, parts: $10})
      },
    init: [],
    xs: @definy.merge-module-names(modules: @core.list-concat(left: $1, right: @core.list-concat(left: $2, right: $0)))
  )
visibility
public
definy.merge-modules (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: vwUBFQJfr5pXYZtsjJ_V1cdO3bFFpPQP87Na2Zuu0us
content hash: e3N_dYpu9hiWMXZqI6QWWfQCwdf5LV7Bbgs-fWcZIdA