<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">That worked, though not sure why I had to delete the .o file.<br><br>On to ghci?<br><br>Michael<br><br>--- On <b>Sun, 1/30/11, Paul L <i><ninegua@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Paul L <ninegua@gmail.com><br>Subject: Re: [Haskell-cafe] Code from Haskell School of Expression hanging.<br>To: "michael rice" <nowgate@yahoo.com><br>Cc: haskell-cafe@haskell.org, "Daniel Fischer" <daniel.is.fischer@googlemail.com><br>Date: Sunday, January 30, 2011, 7:31 PM<br><br><div id="yiv1940552886">Maybe you want to remove Snowflake.o (or even *.o) and then try compiling it again.<div><br></div><div>Regards,</div><div>Paul Liu<br><br><div class="yiv1940552886gmail_quote">On Sun, Jan 30, 2011 at 4:11 PM, michael rice <span dir="ltr"><<a rel="nofollow"
ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>></span> wrote:<br>
<blockquote class="yiv1940552886gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">SimpleGraphics has a bunch of main programs: main0, main1, main2, main3, and main3book. I sequentially changed each to main and ran all five successfully.<br>
<br>Then I did the same for Snowflake.lhs (see code below) which already had a single main function.<br><br>Michael<br><br>==============<br><br>[michael@localhost src]$ ghc --make Snowflake -main-is Snowflake<br>Linking Snowflake ...<br>
/usr/lib/ghc-6.12.3/libHSrtsmain.a(Main.o): In function `main':<br>(.text+0x10): undefined reference to `ZCMain_main_closure'<br>/usr/lib/ghc-6.12.3/libHSrtsmain.a(Main.o): In function `main':<br>(.text+0x18): undefined reference to `__stginit_ZCMain'<br>
collect2: ld returned 1 exit status<br>[michael@localhost src]$<br><br>==============<div><div></div><div class="yiv1940552886h5"><br><br>This code was automatically extracted from a .lhs file that
<br>uses the following convention:
<br> <br>-- lines beginning
with ">" are executable
<br>-- lines beginning with "<" are in the text,
<br> but not necessarily executable
<br>-- lines beginning with "|" are also in the text,
<br> but are often just expressions or code fragments.
<br> <br>> module Snowflake where
<br>> import SOE
<br> <br>> m = 81 :: Int -- multiple of 3 for triangle size
<br>> x = 250 :: Int -- x and y coordinates of
<br>> y = 250 :: Int -- center of snowflake
<br>> colors = [ Magenta, Blue, Green, Red, Yellow ]
<br> <br>> snowflake :: Window -> IO ()
<br>> snowflake w = do
<br>> drawTri w x y m 0 False -- draw first triangle w/flat top
<br>> flake w x y m 0 True -- begin recursion to complete job
<br> <br>> flake :: Window -> Int -> Int -> Int -> Int -> Bool -> IO ()
<br>>
flake w x y m c o = do
<br>> drawTri w x y m c o -- draw second triangle
<br>> let c1 = (c+1)`mod`5 -- get next color
<br>> if (m<=3) then return () -- if too small, we're done
<br>> else do
<br>> flake w (x-2*m) (y-m) (m`div`3) c1 True -- NW
<br>> flake w (x+2*m) (y-m) (m`div`3) c1 True -- NE
<br>> flake w x (y+2*m) (m`div`3) c1 True -- S
<br>> flake w (x-2*m) (y+m) (m`div`3) c1 False -- SW
<br>> flake w (x+2*m) (y+m) (m`div`3) c1 False -- SE
<br>> flake w x (y-2*m) (m`div`3) c1 False -- N
<br> <br>> drawTri :: Window ->
Int -> Int -> Int -> Int -> Bool -> IO ()
<br>> drawTri w x y m c o =
<br>> let d = (3*m) `div` 2
<br>> ps = if o
<br>> then [(x,y-3*m), (x-3*m,y+d), (x+3*m,y+d)] -- side at bottom
<br>> else [ (x,y+3*m), (x-3*m,y-d), (x+3*m,y-d)] -- side at top
<br>> in drawInWindow w
<br>> (withColor (colors !! c)
<br>> (polygon ps))
<br> <br>> main
<br>> = runGraphics (
<br>> do w <- openWindow "Snowflake Fractal" (500,500)
<br>> drawInWindow w (withColor White
<br>> (polygon
[(0,0),(499,0),(499,499),(0,499)]))
<br>> snowflake w
<br>> spaceClose w
<br>> )
<br> <br>> spaceClose :: Window -> IO ()
<br>> spaceClose w
<br>> = do k <- getKey w
<br>> if k==' ' || k == '\x0'
<br>> then closeWindow w
<br>> else spaceClose w
<br> <br> <br></div></div><div class="yiv1940552886im">--- On <b>Sun, 1/30/11, Daniel Fischer <i><<a rel="nofollow" ymailto="mailto:daniel.is.fischer@googlemail.com" target="_blank" href="/mc/compose?to=daniel.is.fischer@googlemail.com">daniel.is.fischer@googlemail.com</a>></i></b> wrote:<br></div><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<div class="yiv1940552886im"><br>From: Daniel Fischer <<a rel="nofollow" ymailto="mailto:daniel.is.fischer@googlemail.com" target="_blank" href="/mc/compose?to=daniel.is.fischer@googlemail.com">daniel.is.fischer@googlemail.com</a>><br>Subject: Re: [Haskell-cafe] Code from Haskell School of Expression hanging.<br>
</div>To: <a rel="nofollow" ymailto="mailto:haskell-cafe@haskell.org" target="_blank" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>,
"michael rice" <<a rel="nofollow" ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>Date: Sunday, January 30, 2011, 6:48 PM<div class="yiv1940552886im"><br><br><div>On Monday 31 January 2011 00:27:41, michael rice wrote:<br>
> And here's the same with GHC. It never gets to linking and creating an<br>> executable the way the GLFW sample program does.<br>><br>> Michael<br>><br>> ===============<br>><br>> [michael@localhost ~]$ cd ./SOE/SOE/src<br>
> [michael@localhost src]$ ghc --make SimpleGraphics.lhs<br>> [2 of 2] Compiling SimpleGraphics ( SimpleGraphics.lhs,<br>> SimpleGraphics.o ) [michael@localhost src]$<br><br>The module name is not Main, so to get an executable, you have to tell ghc <br>
what the Main module is.<br>Assuming SimpleGraphics.lhs contains a main function,<br><br>$ ghc --make SimpleGraphics -main-is SimpleGraphics<br><br>should do it.<br><br>Cheers,<br>Daniel<br><br><br></div></div></blockquote>
</td></tr></tbody></table><br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a rel="nofollow" ymailto="mailto:Haskell-Cafe@haskell.org" target="_blank" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a rel="nofollow" target="_blank" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Paul Liu<br><br>
</div>
</div></blockquote></td></tr></table><br>