On Tue, 2007-07-17 at 15:49 -0400, Scot Drysdale wrote: 
> I am preparing to teach a course this fall from Paul Hudak's _The  
> Haskell School of Expression_.  In running Picture.lhs, one of the  
> example programs form the book, I am getting strange graphics  
> behavior.  I load the program using ghci and type "main".  The  
> graphics window appears, but only one or two of the four shapes is  
> drawn.  But if I resize the window (or let the screen or computer  
> sleep and awaken, or cover the window and then uncover it), all four  
> shapes appear.  When clicking on a shape to bring it to the front,  
> only the last drawn shape appears on the screen.  Again, resizing the  
> window reveals all four shapes drawn correctly.
> The fours files needed to produce this behavior are enclosed, and a  
> full session (using the -v flag on ghci) is shown below.  I modified  
> the files to use the library Graphics.SOE instead of SOEGraphics,  
> which was needed to run under ghc (as opposed to HUGS).

The HGL package which Graphics.SOE is based on is unmaintained and
fairly buggy on several platforms, especially in GHCi since it uses
threads in a way that is not especially nice (or so I have heard) and
GHCi uses the -threaded runtime system which uses multiple real OS
threads so it can expose dodgy uses of threads.

It may work better in Hugs since its implementation of threads is
totally different to that of GHCs and HGL was originally implemented and
tested with Hugs.

Alternatively you could use the implementation of the SOE api that comes
with Gtk2Hs. It's a totally different implementation but has the same
API and tries to preserve the same behaviour (though it's not 100% the
same, there are reports of bugs in the region code). In the latest
version of Gtk2Hs it's possible to use Graphics.SOE.Gtk from GHCi (ie it
works with the -threaded rts)

The latest version is here:

That's the first release candidate for 0.9.12 which should be announced
and released in the next few days. There's also a windows installer
(swap .tar.gz for .exe in the above url). It should work on OSX (but I
can't test it personally so have to rely on people to report problems).

In case you're interested, I've been using Gtk2Hs (though not the SOE
api) for a programming practical for a first year FP course at Oxford
for the past couple of years:
Am FP course at Jyväskylä in Finland has used the SOE api. In fact that
is where the new implementation stems from.


Glasgow-haskell-bugs mailing list

Reply via email to