2009/10/21 Tim Wawrzynczak <[email protected]>
>
> Here's an example in the IO monad:
>
> import Data.IORef
> import System.IO.Unsafe
>
> counter = unsafePerformIO $ newIORef 0
>
> next = do
> modifyIORef counter (+1)
> readIORef counter
>
> Naturally, this uses unsafePerformIO, which as you know, is not kosher...
But you don't close around the Ref like in your schemy example.
mkNext = do
ref <- newIORef 0
return (do modifyIORef ref succ
readIORef ref)
mimic your other code better.
Cheers,
Thu
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe