updating labelled fields
Iavor S. Diatchki
diatchki@cse.ogi.edu
Wed, 08 May 2002 18:27:18 -0700
Hello,
I am not sure if this is what is needed, but you can do the following in
Hugs (with extensions):
data T = T
{ x :: Int
, y :: Char
}
f s@T {x} = s { x = x + 1 }
This increments the first field in the record, and leavs the second one
unchanged.
It makes use of punning, a very useful feature I think, which unfortunately
was removed from Haskell, I am not sure why. It is still supported in
Hugs however.
bye
Iavor