External Publication
Visit Post

[RFC] Mutable records as a GHC extension

Haskell Community [Unofficial] April 6, 2026
Source

AntC2:

I agree the HasField and friends/‘update’ mechanisms are just too perplexing to be worth using.

I guess for record access specifically the coherent approach would be only have access to field labels once a relevant constructor has been scrutinized, but then that creates a non-type that is “the record inside the constructor”, which can’t be passed to functions. This explains why NamedFieldPuns and RecordWildCards extensions are structured the way they are.

Perhaps it would make sense to think of record syntax as a special type, much likeMutableLayout of this proposal, so that it can be repackaged into a separate type if passed to a function, otherwise the reallocation is somehow elided. [After thinking about it some more this would introduce way more problems than it would solve]

Actually, the record doesn’t need a special type, it could be represented by anewtype over the original type with the relevant constructor name on the type level. Have it be only obtainable by pattern matching with a special extension, have getField retrieve the relevant field unsafely.

Anyway, this proposal isn’t about changing the record syntax for ADTs, we shouldn’t focus this hard on that.

Discussion in the ATmosphere

Loading comments...