
Records do leave quite a bit to be desired. But does anybody actually have a concrete alternative proposal yet?
A few months ago I proposed a couple of extensions [1] on -cafe. The jist of it is in the following:
someUpdate :: MyRecord -> MyRecord someUpdate myRecord = myRecord { field1 = f $ field1 myRecord , field2 = g $ field2 myRecord , field3 = h $ filed3 myRecord }
becomes
someUpdate :: MyRecord -> MyRecord someUpdate = \{field1 => f, field2 => g, field3 => h}
The two syntax changes here are: 1. '=' remains as assignment in record updates, but => is added and means 'field is transformed by', and 2. "\{...}" is a first-class "lambda update". It's made possible by the 1 since with 1 you no longer need to reference the entire record anywhere in the update Consider what this would do for nested updates:
UpdateTripleInner :: (Inner->Inner) -> MyTriplyNestedRecord -> MyTriplyNestedRecord UpdateTripleInner f = \{inner1 => \{inner2 => \{inner3 => f }}}
I cringe to imagine what the equivalent is in current Haskell syntax.
Anyone want to try it? Not me!
These extensions, admittedly, don't do anything for the namespacing
problem, which might be a bigger issue than awkward updates. I submit
that it's a different and somewhat unrelated issue, though I'd love to
see something that addresses both (all?) of the issues!
--Jonathan Geddes
[1] http://www.mail-archive.com/haskell-cafe@haskell.org/msg81509.html
On Fri, Nov 12, 2010 at 1:29 PM, Andrew Coppin
On 11/11/2010 11:48 PM, John Lask wrote:
again quoting
http://research.microsoft.com/en-us/um/people/simonpj/Haskell/records.html
"Haskell lacks a serious record system. (The existing mechanism for named fields in data types was always seen as a stop-gap measure.)"
isn't it about time this changed?
Records do leave quite a bit to be desired. But does anybody actually have a concrete alternative proposal yet?
Personally I'm not really keen on TDNR; I'd prefer records that aren't so inconvenient. But I have no idea how to design that.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe