field record update syntax

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... -Alex- ______________________________________________________________ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com

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)}

On Thu, Jan 27, 2005 at 12:59:50PM -0500, 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...
you can use DrIFT to automatically create bar_u to update a field and bar_s to set a field. They also behave nicer than the built in syntax as they pass through constructors without the given field rather than return bottom. John -- John Meacham - ⑆repetae.net⑆john⑈

John Meacham writes:
you can use DrIFT to automatically create bar_u to update a field and bar_s to set a field.
That is exactly what I need. Is there, by any chance, a solution that's based on Template Haskell too? Not that I'd have something against DrIFT; I'm just curious to know. Peter

On Fri, Jan 28, 2005 at 02:36:59PM +0100, Peter Simons wrote:
you can use DrIFT to automatically create bar_u to update a field and bar_s to set a field.
That is exactly what I need. Is there, by any chance, a solution that's based on Template Haskell too? Not that I'd have something against DrIFT; I'm just curious to know.
A project I thought would be neat is to create a common framework so the same deriving rules could work with DrIFT or template haskell. It shouldn't be too tough. you couldn't use the template haskell special syntax though. John -- John Meacham - ⑆repetae.net⑆john⑈
participants (4)
-
Henning Thielemann
-
John Meacham
-
Peter Simons
-
S. Alexander Jacobson