[Haskell-cafe] Rewriting a Python application to Haskell

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sat Sep 2 06:52:48 EDT 2006

On Sat, 2006-09-02 at 11:00 +0400, Bulat Ziganshin wrote:
> Hello Neil,
> Friday, September 1, 2006, 6:47:12 PM, you wrote:
> > I have no idea about wxHaskell and STM, but I found out that hard way
> > that Gtk2Hs + threads = bad idea.

No, no, Gtk2Hs + threads = great idea :-)

It's just that currently we can't fully follow through on the promise.
There are some tricky problems.

> Duncan Coutts, gtk2hs author, writes the same and proposed solution -
> use dedicated thread to execute all graphics commands and send these
> commands to the thread using Chan. it's just several lines of code:

I mentioned this thread + channel technique as a way of taking advantage
of threads to avoid having lots of IORefs, not as a way to avoid
threading problems.

> Just mention that forkOS, but not forkIO, should be used. one my
> friend tried this setting and it worked fine

On the contrary, using forkOS and the threaded rts is highly likely to
break your GUI program at the moment because there is now way to ensure
that all the GUI operations are done on the right OS thread.

The way to make it work is to use the single threaded rts and read the
FAQ on the issue. The issue that Neil ran into is specific to windows.
I've used threads in other Gtk2Hs progs quite happily. On windows
there's something odd going on with the RTS scheduler that we couldn't
quite pin down.


More information about the Haskell-Cafe mailing list