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

Thomas Friedrich info at suud.de
Sat Jul 25 10:50:01 EDT 2009


Bernhard Lehnert wrote:
> Hi list,
>
> using gtk2hs I would like to count how often a Menu has been selected
> (well, not really, but it kind of breaks down to this):
>
>
>     let a = 0
>     onActivateLeaf menuAddOne $ do
>         let a = a+1
>         print a
>
>
> This leads to a stack overflow. Obviously a=a+1 is iterated over and
> over again. But how can I add something each time the menu is activated?
> (Actually I want to open a FileDialog and add the contents of a file to
> a list but for now, counting would be great).
>
> Thanks to everyone for reading,
> Bernhard
>
>
>   

I would suggest having a look at Control.Concurrent.MVar

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html

Best,
Thomas



More information about the Beginners mailing list