Re: Bug involving graphics under OS X

2007-07-22 Thread Duncan Coutts
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:
http://haskell.org/gtk2hs/gtk2hs-0.9.11.3.tar.gz

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:
http://haskell.org/gtk2hs/archives/2005/11/01/university-courses-using-gtk2hs-for-teaching/
Am FP course at Jyväskylä in Finland has used the SOE api. In fact that
is where the new implementation stems from.


Duncan

___
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Bug involving graphics under OS X

2007-07-22 Thread Scot Drysdale
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).


I am running ghci, version 6.6.1, on an Apple MacBook Pro (2.16 GHz  
Intel Core Duo, 1 GB 666 MHz Ram) running OS X version 10.4.10.  I  
get similar behavior on an Apple iMac (1.6 GHz PowerPC G5) running  
10.4.10.


Scot Drysdale
Professor of Computer Science, Dartmouth College


scot-macbookpro:~/Documents/Courses/CS 8/SOE/bugtest scot$ ghci -v  
Picture.lhs

   ___ ___ _
  / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |  GHC Interactive, version 6.6.1, for Haskell  
98.

/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Using package config file: /opt/local/lib/ghc-6.6.1/package.conf
wired-in package base mapped to base-2.1.1
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-2.1
Hsc static flags: -static
Loading package base ... linking ... done.
wired-in package base mapped to base-2.1.1
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-2.1
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
wired-in package base mapped to base-2.1.1
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-2.1
*** Chasing dependencies:
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Upsweep completely successful.
*** Deleting temp files:
Deleting:
*** Chasing dependencies:
Created temporary directory: /tmp/ghc4524_0
*** Literate pre-processor:
/opt/local/lib/ghc-6.6.1/unlit -h Picture.lhs Picture.lhs /tmp/ 
ghc4524_0/ghc4524_0.lpp

*** Literate pre-processor:
/opt/local/lib/ghc-6.6.1/unlit -h Region.lhs Region.lhs /tmp/ 
ghc4524_0/ghc4524_1.lpp

*** Literate pre-processor:
/opt/local/lib/ghc-6.6.1/unlit -h Shape.lhs Shape.lhs /tmp/ghc4524_0/ 
ghc4524_2.lpp

*** Literate pre-processor:
/opt/local/lib/ghc-6.6.1/unlit -h Draw.lhs Draw.lhs /tmp/ghc4524_0/ 
ghc4524_3.lpp

Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
compile: input file /tmp/ghc4524_0/ghc4524_2.lpp
*** Checking old interface for main:Shape:
[1 of 4] Compiling Shape( Shape.lhs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 501
*** Simplify:
Result size = 910
Result size = 681
Result size = 681
*** Tidy Core:
Result size = 681
*** CorePrep:
Result size = 831
*** ByteCodeGen:
*** Deleting temp files:
Deleting:
compile: input file /tmp/ghc4524_0/ghc4524_3.lpp
*** Checking old interface for main:Draw:
[2 of 4] Compiling Draw ( Draw.lhs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 827
*** Simplify:
Result size = 1173
Result size = 1093
Result size = 1093
*** Tidy Core:
Result size = 1093
*** CorePrep:
Result size = 1351
*** ByteCodeGen:
*** Deleting temp files:
Deleting:
compile: input file /tmp/ghc4524_0/ghc4524_1.lpp
*** Checking old interface for main:Region:
[3 of 4] Compiling Region   ( Region.lhs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 827
*** Simplify:
Result size = 1134
Result size = 945
Result size = 945
*** Tidy Core:
Result size = 945
*** CorePrep:
Result size = 1215
*** ByteCodeGen:
*** Deleting temp files:
Deleting:
compile: input file /tmp/ghc4524_0/ghc4524_0.lpp
*** Checking old interface for main:Picture:
[4 of 4] Compiling Picture  ( Picture.lhs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 1624
*** Simplify:
Result size = 2423
Result size = 2083
Result size = 2083
*** Tidy Core:
Result size = 2083
*** CorePrep:
Result size = 2443
*** ByteCodeGen:
*** Deleting temp files:
Deleting:
Upsweep completely successful.
*** Deleting temp files:
Deleting: