Re: [Haskell-cafe] field record update syntax
(Moved to Haskell list because this is now a suggestion for the language) I do a lot of this soft of thing. foo {bar = fn $ bar foo ,baz = fn2 $ baz foo } It would be much nicer if this syntax did the equivalent: foo {bar \= fn ,baz \= fn2 } -Alex- On Thu, 27 Jan 2005, Henning Thielemann wrote:
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)}
______________________________________________________________ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
"S. Alexander Jacobson" <alex@alexjacobson.com> wrote:
(Moved to Haskell list because this is now a suggestion for the language) I do a lot of this soft of thing. foo {bar = fn $ bar foo ,baz = fn2 $ baz foo }
It would be much nicer if this syntax did the equivalent: foo {bar \= fn ,baz \= fn2 } -Alex-
What about 'lifting' this higher? You are (essentially) suggesting a nice syntax for constructing functions from a record to itself. While your syntax is essentially pointfree, the semantics is 'pointwise' (in that it refers to a specific record) -- not to be confused with the fact that any such function needs to be done compontent-wise. Wouldn't be even more convenient (as well as more 'functional') if a syntax like \foo {bar \= fn ,baz \= fn2 } built a record-to-record function? [The \foo might even be enough to allow bar = fn instead of bar = fn]. Jacques
participants (2)
-
Jacques Carette -
S. Alexander Jacobson