deep record update

Barney Hilken b.hilken at
Mon Sep 19 15:09:05 CEST 2011

All this talk about records got me thinking. I don't really like the current syntax for record update (because it looks too much like function application) but here is an extension to it which might be useful.

If you use nested records, many languages allow you to update the inner records directly, for example rect.bottomLeft.xCoord += 3. We could allow a similar thing in Haskell by extending the syntax like this:

fbind	->	qvar = exp
		|	qvar { fbind1 , ... , fbindn }


	rec { l1 { l2 = x }}

would mean

	rec { l1 = (l1 rec) { l2 = x }}

The advantage (apart from convenience) is that we don't have to repeat rec, which could be a complex expression.

Is this any use?


More information about the Glasgow-haskell-users mailing list