Proposal: FirstClassFieldUpdates

Simon Peyton-Jones simonpj at microsoft.com
Thu Aug 6 07:11:59 EDT 2009


| Proposal: FirstClassFieldUpdates
| 
| Summary:
| Add some syntax that makes field updates into functions.

I'm wary about occupying too much "syntactic space" with Haskell's named-field notation.  If you had a keyword, like
	update { foo = bar }
meaning
	\x. x { foo = bar }
that'd get you into a new syntactic space.  But braces alone are so precious that I'm not sure that record updates justify consuming them.


On a related matter, people want to use record syntax for GADTs and existentials.   For record selection and construction these are more or less fine (ie one can make a sensible spec).  But record update is another matter.  Haskell 98 says that record update can change the type of a record (contrary to some posts in this thread), but the specification becomes really rather tricky for GADTs and existentials. Indeed, I was going to propose that in H Prime we might consider making update *not* change the type, backing away from the current H98 story, but one that makes the spec a lot easier.  But various people have been arguing in favour of the H98 story so I may have an uphill struggle!

Simon



More information about the Haskell-prime mailing list