
21 May
2013
21 May
'13
3:08 p.m.
Hi Adrian,
data Thing = Thing Int Int Int Int Int rewriteFourth :: Int -> Thing -> Thing rewriteFourth x (Thing a b c _ e) = Thing a b c x e
Is there a better way?
If you've nested data structures, than lenses are the way to go, but in your case using record syntax might also help. data Thing = Thing { a :: Int, b :: Int, c :: Int, d :: Int, e :: Int } rewriteFourth :: Int -> Thing -> Thing rewriteFourth x thing = thing {d = x} Greetings, Daniel