Code from Haskell School of Expression hanging.

I got Hudak's Haskell School of Expression today and just tried a couple of the graphics programs from the software I downloaded at the book site. Both seem to hang on opening a window. Is there a fix for this problem? I'm on a Fedora 14 Linux (32-bit) box running GHC version 6.12.3. Michael ============ *SimpleGraphics> :l Snowflake.lhs [1 of 2] Compiling SOE ( SOE.hs, interpreted ) [2 of 2] Compiling Snowflake ( Snowflake.lhs, interpreted ) Ok, modules loaded: Snowflake, SOE. *Snowflake> main ============ This code was automatically extracted from a .lhs file that uses the following convention: -- lines beginning with ">" are executable -- lines beginning with "<" are in the text, but not necessarily executable -- lines beginning with "|" are also in the text, but are often just expressions or code fragments.
module Snowflake where import SOE m = 81 :: Int -- multiple of 3 for triangle size x = 250 :: Int -- x and y coordinates of y = 250 :: Int -- center of snowflake colors = [ Magenta, Blue, Green, Red, Yellow ] snowflake :: Window -> IO () snowflake w = do drawTri w x y m 0 False -- draw first triangle w/flat top flake w x y m 0 True -- begin recursion to complete job flake :: Window -> Int -> Int -> Int -> Int -> Bool -> IO () flake w x y m c o = do drawTri w x y m c o -- draw second triangle let c1 = (c+1)`mod`5 -- get next color if (m<=3) then return () -- if too small, we're done else do flake w (x-2*m) (y-m) (m`div`3) c1 True -- NW flake w (x+2*m) (y-m) (m`div`3) c1 True -- NE flake w x (y+2*m) (m`div`3) c1 True -- S flake w (x-2*m) (y+m) (m`div`3) c1 False -- SW flake w (x+2*m) (y+m) (m`div`3) c1 False -- SE flake w x (y-2*m) (m`div`3) c1 False -- N drawTri :: Window -> Int -> Int -> Int -> Int -> Bool -> IO () drawTri w x y m c o = let d = (3*m) `div` 2 ps = if o then [(x,y-3*m), (x-3*m,y+d), (x+3*m,y+d)] -- side at bottom else [ (x,y+3*m), (x-3*m,y-d), (x+3*m,y-d)] -- side at top in drawInWindow w (withColor (colors !! c) (polygon ps)) main = runGraphics ( do w <- openWindow "Snowflake Fractal" (500,500) drawInWindow w (withColor White (polygon [(0,0),(499,0),(499,499),(0,499)])) snowflake w spaceClose w ) spaceClose :: Window -> IO () spaceClose w = do k <- getKey w if k==' ' || k == '\x0' then closeWindow w else spaceClose w

On Sunday 30 January 2011 02:49:27, michael rice wrote:
I got Hudak's Haskell School of Expression today and just tried a couple of the graphics programs from the software I downloaded at the book site. Both seem to hang on opening a window. Is there a fix for this problem? I'm on a Fedora 14 Linux (32-bit) box running GHC version 6.12.3.
It might be that you need to compile the code. And even then, perhaps it doesn't run correctly in ghci, iirc, gtk2hs used to not run in ghci (some threading issues, I'm not sure whether they've been resolved), maybe the graphics library used by HSOE has similar issues. Try and hope for the best.

I'm using the OpenGL stuff (GLFW). Same set of problems?
Michael
--- On Sat, 1/29/11, Daniel Fischer
I got Hudak's Haskell School of Expression today and just tried a couple of the graphics programs from the software I downloaded at the book site. Both seem to hang on opening a window. Is there a fix for this problem? I'm on a Fedora 14 Linux (32-bit) box running GHC version 6.12.3.
It might be that you need to compile the code. And even then, perhaps it doesn't run correctly in ghci, iirc, gtk2hs used to not run in ghci (some threading issues, I'm not sure whether they've been resolved), maybe the graphics library used by HSOE has similar issues. Try and hope for the best.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 1/29/11 21:27 , michael rice wrote:
I'm using the OpenGL stuff (GLFW). Same set of problems?
None of the lower level libraries support multithreading. If any of those libraries use FFI bindings that run in a bound thread, they'll fail in the threaded runtime. gtk2hs was modified to allow ghci to work, IIRC. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1FDIkACgkQIn7hlCsL25V6twCgn5JcK8Y0yerY5EkiyJyULOeM 6sYAoLkj8JS/CfquHfHCzl3DbGPKAhgo =Ybo6 -----END PGP SIGNATURE-----

OK, what about Hugs? I used Cabal to download the GLFW package to GHC. Must I do the same from Hugs? Or is this also a fools mission?
From: http://plucky.cs.yale.edu/soe/software1.htm
"follow the installation instructions for Gtk2Hs at
http://www.haskell.org/gtk2hs, then import the module Graphics.SOE.Gtk
instead of SOE.hs in your code."
That link appears to be broken.
What must I do? Or am I at a dead end?
Michael
[michael@localhost ~]$ cd ./SOE/SOE/src
[michael@localhost src]$ hugs
__ __ __ __ ____ ___ _________________________________________
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005
||---|| ___|| World Wide Web: http://haskell.org/hugs
|| || Bugs: http://hackage.haskell.org/trac/hugs
|| || Version: September 2006 _________________________________________
Haskell 98 mode: Restart with command line option -98 to enable extensions
Type :? for help
Hugs> :l Snowflake.lhs
ERROR "./SOE.hs" - Can't find imported module "Graphics.UI.GLFW"
Hugs>
--- On Sun, 1/30/11, Brandon S Allbery KF8NH
I'm using the OpenGL stuff (GLFW). Same set of problems?
None of the lower level libraries support multithreading. If any of those libraries use FFI bindings that run in a bound thread, they'll fail in the threaded runtime. gtk2hs was modified to allow ghci to work, IIRC. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1FDIkACgkQIn7hlCsL25V6twCgn5JcK8Y0yerY5EkiyJyULOeM 6sYAoLkj8JS/CfquHfHCzl3DbGPKAhgo =Ybo6 -----END PGP SIGNATURE----- _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I don't know about the rest of your question, but I've found that a lot of broken links on haskell.org can be fixed by inserting /haskellwiki/ between the .org/ and the term in the broken URL. Therefore, the link you were looking for is: http://www.haskell.org/haskellwiki/Gtk2Hs On 1/30/11 10:28 AM, michael rice wrote:
OK, what about Hugs? I used Cabal to download the GLFW package to GHC. Must I do the same from Hugs? Or is this also a fools mission?
From: http://plucky.cs.yale.edu/soe/software1.htm
"follow the installation instructions for Gtk2Hs at http://www.haskell.org/gtk2hs, then import the module Graphics.SOE.Gtk instead of SOE.hs in your code."
That link appears to be broken.
What must I do? Or am I at a dead end?
Michael
[michael@localhost ~]$ cd ./SOE/SOE/src [michael@localhost src]$ hugs __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: September 2006 _________________________________________
Haskell 98 mode: Restart with command line option -98 to enable extensions
Type :? for help Hugs> :l Snowflake.lhs ERROR "./SOE.hs" - Can't find imported module "Graphics.UI.GLFW" Hugs>
--- On *Sun, 1/30/11, Brandon S Allbery KF8NH /
/* wrote: From: Brandon S Allbery KF8NH
Subject: Re: [Haskell-cafe] Code from Haskell School of Expression hanging. To: haskell-cafe@haskell.org Date: Sunday, January 30, 2011, 2:00 AM -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 1/29/11 21:27 , michael rice wrote: > I'm using the OpenGL stuff (GLFW). Same set of problems?
None of the lower level libraries support multithreading. If any of those libraries use FFI bindings that run in a bound thread, they'll fail in the threaded runtime. gtk2hs was modified to allow ghci to work, IIRC.
- -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1FDIkACgkQIn7hlCsL25V6twCgn5JcK8Y0yerY5EkiyJyULOeM 6sYAoLkj8JS/CfquHfHCzl3DbGPKAhgo =Ybo6 -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks. I already found it, and there doesn't seem to be any support for Linux.
Michael
--- On Sun, 1/30/11, JETkoten
participants (4)
-
Brandon S Allbery KF8NH
-
Daniel Fischer
-
JETkoten
-
michael rice