[Haskell-cafe] field record update syntax

Henning Thielemann lemming at henning-thielemann.de
Thu Jan 27 14:20:40 EST 2005


On Thu, 27 Jan 2005, S. Alexander Jacobson wrote:

> I have a lot of code of the form
>
>    foo {bar = fn $ bar foo}
>
> Is there a more concise syntax?  I am thinking
> the record equivalent of C's foo+=5...
>
> I imagine there is some operator that does this e.g.
>
>     foo {bar =* fn}
>
> But I don't know what it is...

If you have only few different record fields you may like to define an
update function for each record field.

updateBar fn foo = foo {bar = fn (bar foo)}



More information about the Haskell-Cafe mailing list