Proposal: FirstClassFieldUpdates

Isaac Dupree ml at
Mon Jul 27 13:05:56 EDT 2009

Jon Fairbairn wrote:
> Parenthesis around updates would make them into functions, ie
> ({a=1,b=2,...}) would mean the same as (\d -> d{a=1,b=2,...}), but be
> more concise.

yes it is, however field updates are occasionally slightly annoying, 
since they can't change something's type at all, IIRC.  Say,
data C nx ny = C { x :: nx, y :: ny }
x_set :: nx2 -> C nx1 ny -> C nx2 ny
--x_set x2 c = c {x = x2}  --type error
--x_set x2 = ({x = x2})  --still a type error
x_set x2 c = C {x = x2, y = y c} --legal

Which is possibly a reason to stay away from field-update syntax on some 
occasions, and therefore not want it to get a more prominent place in 
the language if it doesn't deserve it yet.


More information about the Haskell-prime mailing list