[Haskell-cafe] records proposals list
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Mon Nov 21 12:44:43 EST 2005
David Roundy <droundy at abridgegame.org> writes:
> I'd benefit from just a list of problems that the record proposals want to
> solve.
>
> 1. The field namespace issue.
> 2. Multi-constructor getters, ideally as a function.
> 3. "Safe" getters for multi-constructor data types.
> 4. Getters for multiple data types with a common field.
> 5. Setters as functions.
> 6. Anonymous records.
> 7. Unordered records.
Personally, I would quite like to have "first-class labels". By this
I mean the ability to pass record labels as arguments, and to return
them as results.
With this one generalisation, it would be possible to cover most of
the wishlist above. A generic getter and setter could be defined
simply as polymorphic functions e.g.
get :: Label n -> Record (n::a | r) -> a
set :: Label n -> a -> Record r -> Record (n::a | r)
upd :: Label n -> (a->a) -> Record (n::a | r) -> Record (n::a | r)
You could even define your own preferred syntactic sugar for these
operations e.g.
r . l = get l r
.. and the higher-order uses fall out for free
map (get foo) listOfRecords
There are several proposals incorporating this idea.
Oleg Kiselyov and Ralf Lämmel, "Haskell's overlooked object system"
http://homepages.cwi.nl/~ralf/OOHaskell/
Daan Leijen, "First-class labels for extensible rows"
http://www.cs.uu.nl/~daan/pubs.html
Benedict Gaster and Mark Jones, "A Polymorphic Type System for
Extensible Records and Variants"
http://www.cse.ogi.edu/~mpj/pubs/polyrec.html
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list