
Aha! I was using record syntax but I didn't know I could use it like that.
Thanks! Now for that lenses thing.
On 22 May 2013 03:11, "Daniel Trstenjak"
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
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners