[Haskell-beginners] Re: Count how often a menu has been selected

Bernhard Lehnert b.lehnert at gmx.de
Sat Jul 25 14:22:33 EDT 2009


Felipe wrote:
> If you want variables in the impure sense, use IORefs.
>
>    import Data.IORef
>
>    ...
>
>    a <- newIORef 0
>    onActivateLeaf menuAddOne $ do
>        modifyIORef a (+1)
>        print a
>

Hi Felipe,

this works great except for the "print a" part which I replaced by:

b <- readIORef a
print b

I should now have the tools to try to implement my real life problem. 
Thank you,
Bernhard



More information about the Beginners mailing list