I’m writing a haskell program with GUI. When I write the following piece of code
onClicked btn $ do
print 1
onClicked btn $ do
print 2
Pressing btn resulted in printing 1 and 2 simultaneously
How can I override the function definition such that the last definition replaces the first one and prints 2 only
Background: I’m writing a minesweeper game. When a button has a mine it explode, then I try to play again and define the same button to be cleared of mines, but pressing it explode a mine again because of the first definition.
Thanks
Use the connection returned by
onClickedto unregister event handlers:Also,
onClickedis deprecated; when possible, you should use the newonmechanism instead. Its use is very similar: