Nicolas Pouillard wrote:
Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 
2009:
do acc <- get
   put (acc+1)
   ...

Since this pattern occurs often 'modify' is a combination of get and put:

do modify (+1)
   ...

Though the caveat about laziness applies here as well. modify is famously lazy which can lead to space leaks and stack overflows. Better would be to define and use your own strict version:

    modify' f = get >>= \x -> put $! f x

--
Live well,
~wren
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to