Explorer

definy.apply-part-change

description
Apply a part change to the modules of a snapshot (adding the module when it is new)
type
Fn(
  modules: List<@core.project-snapshot-module>,
  module_name: String,
  name: String,
  content_hash: Union{#none, #some(String)}
) -> List<@core.project-snapshot-module>
expression
fn(modules$0, module_name$1, name$2, content_hash$3) =>
  match @core.list-fold(
      T: @core.project-snapshot-module,
      A: Boolean,
      reducer: fn(acc$4, item$5) =>
        @core.or(left: $4, right: @core.equal(left: $5.name, right: $1)),
      init: false,
      xs: $0
    ) {
    true =>
      @core.list-map(
        T: @core.project-snapshot-module,
        U: @core.project-snapshot-module,
        f: fn(item$6) =>
          match @core.equal(left: $6.name, right: $1) {
            true =>
              {
                name: $6.name,
                description: $6.description,
                visibility: $6.visibility,
                parts: @definy.apply-module-part-change(parts: $6.parts, name: $2, content_hash: $3)
              },
            false =>
              $6
          },
        xs: $0
      ),
    false =>
      match $3 {
        #none(_) =>
          $0,
        #some(hash$7) =>
          @core.list-append(list: $0, item: @definy.new-snapshot-module(name: $1, part_name: $2, content_hash: $7))
      }
  }
visibility
public
definy.apply-part-change (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: UlgzgAViBOEy1H4YgBIzVXXmv9E8AhxwNxdI3uYOW1M
content hash: 1G5A1Z_bAPLSdpVMhQfUz_rf_tekDpnfofhEu9Av4KA