[Haskell] Re: [Haskell-cafe] field record update syntax

S. Alexander Jacobson alex at alexjacobson.com
Thu Jan 27 15:47:46 EST 2005


(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


More information about the Haskell mailing list