openlang

Can record updates be disambiguated explicitly?

The conversation continues 3

Follow the reasoning
  1. Permalink

    Using RecordWildCards, one option is case recordA of MkA {..} -> MkA {c = 17, ..}, though I also find that unsatisfactory.

    Being able to write just MkA {c = 17, ..recordA} to bring every field of recordA over into the fresh record would be nice.

  2. Permalink

    Alternatively

    main = do
        print $ let MkA {..} = recordA in MkA {c = 17, ..}

    Worth mentioning that despite its ugly syntax, this makes clear that you're allocating entirely fresh data rather than changing the existing data in place. I'd therefore favor a notation along these lines

    MkA { c = 17
        , .. = recordA
        }

Other sides of the same question

  1. How can I subclass a class inside another class?

    Hi, In a package whose code is outside my control, there is a hierarchy of classes arranged as follows: I'm trying to add a w…

    Replies 1Latest activity scala
  2. Comparing have with let bindings in Lean4

    I've observed that these two expressions and behave identically. This also happens in theorem proofs. Are they interchangeabl…

    Replies 3Latest activity lean-4
  3. TypeScript Map initialization with string array entries

    I'm creating a Map whose entries each hold an array of strings. How can I declare its type and initialize it together in one…

    Replies 2Latest activity typescript