[Haskell-cafe] Pure functional GUI (was

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Aug 9 06:53:03 EDT 2007


On Thu, 2007-08-09 at 08:59 +0800, Hugh Perkins wrote:
> To be fair, GTK is pretty standard.  This is so even for "big name"
> gc'd imperative languages such as C#.  Sure, you can use Windows.Forms
> in C#, but you often wouldnt, because of the patent burden.
> Also, gtk in partnership with glade rocks! 
>  
> How easy is gtk to use from haskell by the way?  In gc'd imperative
> languages, typically only one thread is allowed to communicate with
> the GUI, and you need to set up a whole bunch of message-parsing stuff
> to communicate with other threads.  To what extent is this easier in
> Haskell?

The story on this isn't as nice as it could be. It depends on which GHC
runtime system you choose to use. In the single threaded rts, you can
use threads willy nilly as they all run in the context of one OS thread
(though it requires a little bit of code to set up cooperative
scheduling). In the fully threaded rts you have to be very careful to
only use GUI stuff from a single OS thread. Gtk2Hs provides a couple
functions to post actions to the main GUI thread.

We've been thinking of ways to make this more transparent but it's not
so easy.

> Other question on using gtk from haskell: how easy is it to integrate
> with glade?  ie, can we directly bind glade form elements to haskell
> variables?  How easy is it to bind events to glade form elements from
> within Haskell?

It's pretty easy, see the Gtk2Hs/Glade tutorial:

http://haskell.org/gtk2hs/docs/tutorial/glade/


Duncan



More information about the Haskell-Cafe mailing list