[Haskell-cafe] what GUI library should i select?

Sebastian Sylvan sylvan at student.chalmers.se
Mon Nov 13 11:35:03 EST 2006

On 11/13/06, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> Hello Neil,
> Monday, November 13, 2006, 5:06:02 PM, you wrote:
> > http://haskell.org/~duncan/gtk2hs/gtk2hs-0.9.10.exe
> > That's the most recent Gtk2Hs for 6.4.2.
> the http://haskell.org/gtk2hs/download/ page says that gtk2hs is
> available only for 6.4.1
> >> > The one thing you should be aware of is that Windows + Threading +
> >> > Gtk2Hs + Gtk + GHC = Pain.
> >>
> >> why? are you tried to call Gtk2Hs from only one thread?
> > I think so, yes. Or there are bizare -threaded restrictions. Only
> > Duncan (and perhaps Simon Marlow) understand this. I merely got bit by
> > it...
> it will be great to see comments about this. it's impossible to write
> my program without using threaded RTS

I'm not an expert, but I think the only solutions available depend on
some sort of polling.
E.g. you could start the GUI in a single bound thread, and then pass
in all GUI calls to a channel. Then you would attach an event handler
to idle event (or a timer) which checks to see if there are any items
in the channel, and if so runs them in the GUI thread.

The problem is that you can't actually run GUI actions from other
threads, you can only schedule them to be run by the GUI thread, and
you can't actually "insert" your "block on the UI actions queue as
well as message queue" in the GTK event loop. So you have to every now
and then do this yourself. This could end up in a situation where you
very often check this channel and it's empty, which uses unnecessary
resources, or it could end up in a situation where you don't check it
often enough and any UI actions caused by other threads get delayed.

I suspect that a more sophistated scheduler could be written which
helps with most of this (i.e. use a timer with some default value, if
there are many items in the channel then decrease the timout value, if
there are no items in the channel increase the timout value up to some

Sebastian Sylvan
UIN: 44640862

More information about the Haskell-Cafe mailing list