Re: Count how often a menu has been selected

25 Jul
2009
25 Jul
'09
2:22 p.m.
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

25 Jul
25 Jul
9:52 p.m.
New subject: Count how often a menu has been selected
On Sat, Jul 25, 2009 at 08:22:33PM +0200, Bernhard Lehnert wrote:
this works great except for the "print a" part which I replaced by:
b <- readIORef a print b
Woops, sorry :). Tip: most haskellers would prefer either readIORef a >>= print or print =<< readIORef a even if you are already in a 'do' block. -- Felipe.
5776
Age (days ago)
5777
Last active (days ago)
1 comments
2 participants
participants (2)
-
Bernhard Lehnert
-
Felipe Lessa