[Haskell-cafe] adding state in GUIs (qtHaskell)

Michael Mossey mpm at alumni.caltech.edu
Thu Sep 10 17:13:51 EDT 2009



Duncan Coutts wrote:
> On Wed, 2009-09-09 at 18:29 -0700, Michael P Mossey wrote:
>> I'm trying to learn qtHaskell. I realize few people on this list know anything 
>> about qtHaskell, but I have a question that probably relates to all GUIs as 
>> implemented in Haskell. I just need a hint that could help me figure out the 
>> next step, which I might be able to infer from the qtHaskell API.
> 
> Ultimately it's done by some kind of mutable state, either an IORef,
> MVar or a thread.
> 
> On top of these you can layer nicer stuff like a state monad (with a
> 'runState' function that saves and restores from an IORef).
> 
> A personal favourite of mine is having the GUI event handler post data
> over a channel to a thread. That thread reads from the channel and deals
> with the events. The state of the GUI app is then held as local
> parameters in that thread.
> 
> Doing this of course requires that the GUI lib you're using can cope
> with normal Haskell (forkIO) threads. This is possible with gtk2hs, I
> don't know about the others.

Hi Duncan, thanks for the reply. Can you point me to some code examples 
that do these things?

-Mike


More information about the Haskell-Cafe mailing list