On 08.07.2010 11:15, Michael Mossey wrote:
Whoa, I just realized I'm not using 'modify' to full advantage. This can
be written

incrCursor = modify incrCursor'
incrCursor' (PlayState cursor len verts doc) =
PlayState (min (cursor+1)(len - 1)) len verts doc)

Thats what lambdas are good for:

incrCursor = modify $ \p@(PlayState c l _ _) -> p { cursor = min (c+1) (l-1) }

Or...

incrCursor = modify $ \...@playstate { cursor = c, len = l } -> p { cursor = min (c+1) (l-1) }

:)
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to