Updating records haskell
The standard explanation that I've heard as to why no solution has been implemented to this day is that there are too many nice proposals to choose from.
To me this implies that there will be resources found to target at this problem as soon as an optimal proposal is presented.
Anyway, IMO, subtyping is evil and goes against the standard "open-world" approach of Haskell and induces code coupling.
Yes, but it feels more like a workaround and it doesn't approach the issue of first-class records at all.
Is there a way to declare default value of some fields when defining a new record type?
You cannot associate default values with a type, but you can define as many record values as you like and use them as basis for updating elements.
There's even an idea to make tuples a special case of these records, e.g.: Interesting project, but it's very different to current suggestion. record types - all those that provide the required fields with the required types irrespective of any other fields. A class type in OOP represents the class itself in some contexts, and the set of classes including all subclasses in others - particularly as part of a pointer/reference type.
Basically as different as "HList" package is from a tuple. Even so, I was impressed by the way Haskell handles existentials - the "any of these types" is distinct from the "precisely this type", so you get to explicitly choose which behavior you want.
This should peaceably coexist with -XOverloaded Record Fields but I don't see a way to integrate the two.I expect records made with it to be highly reluctant to compiler optimizations and definitely to occupy more memory. I may be worrying over nothing, and I can see a kind of least-upper-bound semilattice-of-fields argument for treating the set-of-types as a single type, but I still think it's a good idea to differentiate between this-exact-type and forall-matching-types.The complexity of the interface is another point against. I believe it's possible the more if we trigger the community to at last unite and draw a decent attention to this problem.The voice of major figures like yourself wouldn't hurt.
Benefits the current proposal and by Adam Gundry has over this gist:1.) It is actually being implemented. He now works for Well-Typed, so he'll keep getting paid to make it real.2.) It doesn't steal syntax that is currently in use.