[Haskell] How to use STM in GUI applications?

Thorsten Seitz thorsten.seitz at web.de
Mon Dec 4 17:03:56 EST 2006


Hello,

I'm very intrigued by the concepts of STM but I'm having difficulties to see 
how a TVar based model can be used by a GUI application (e.g. Gtk2hs):

For example, I'd like to update the GUI (e.g. changing widget sensitivity) 
upon changes in the model. 
But changing the sensitivity of a widget is an IO operation which cannot be 
initiated atomically by a model change which is an STM operation. Therefore 
the GUI change cannot be executed atomically together with the model change.
This means for example that I can still press a button although the model has 
changed such that the button action is not allowed anymore. All I can do is 
check the condition of the model when the button is pressed and then ignore 
the button press which is not very satisfying for the user.

Is it simply not appropriate to use TVar based models in a GUI application? 
Maybe STM should be more used like a service for MVar based GUI models?

Thanks for any help!

-Thorsten



More information about the Haskell mailing list