updating labelled fields

Simon Peyton-Jones simonpj@microsoft.com
Fri, 10 May 2002 00:39:36 -0700


| So, as it stands the proposal is to add the following pieces of sugar:
|=20
|   1)  ({assignments})     becomes  \x->x{assignments}
|   2)  x{as, field =3D, bs}  becomes  \y->x{as, field =3D y, bs}
|   3)  x{as, field, bs}    becomes  \f->x{as, field =3D f (field x), =
bs}

...
=20
| Assuming I can ever get my cvs'd copy of ghc to compile=20
| (sigh), I would be willing to implement this if there are no=20
| objections...

Hal, it's fine for you to modify and distribute your copy of GHC, of
course,
but I'm not yet convinced that Simon and I want to put this change in
the mainstream
GHC.  It's easier to add a feature than to remove it, and GHC already=20
arguably suffers from feature-itis.  (Perhaps, though, people will love
your
change and nag us to put it in. The more people that ask the keener we
are
to do something.)

While you are thinking about implementation, don't forget the type
checking
part.  I recall that correct type checking of Haskell records was a bit
harder
than it looked.

Incidentally, I'm working with Tim Shead on a sort of meta-programming
facility (somewhat like a fully-integrated Drift, only typechecked) that
would
let you generate update functions for each field automatically; that
might help towards the same goal.

Simon