8 Mar
2002
8 Mar
'02
1:49 a.m.
If I have:
data MyType = MT { x :: Int, y :: Char }
How do I update the Int value of MyType leaving the Char value unaffected? I tryied something like:
MT {x = newValue}
but GHC gave me a warning about the Char value and it indeed caused strange effects. Of course, it is possible to do something like
update :: MyType -> Int -> MyType update mt newValue = MT {x = newValue, y = oldValue} where oldValue = y mt
but this really annoys me when MyType has too many fields. Suggestions? Thanks a lot, -- Andre