[RFC] Mutable records as a GHC extension
AntC2:
I agree the
HasFieldand 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 like MutableLayout of this proposal, so that it can be repackaged into a separate type if passed to a function, otherwise the reallocation is somehow elided.
Regardless, this proposal isn’t about changing the record syntax for ADTs, we shouldn’t focus this hard on that.
Discussion in the ATmosphere