PC sent me a copy of Hudak’s The Haskell School of Expression for my birthday. I was trying to get started with some of the code in the book and could not find a good writeup on it. Here is how I got it going on my Ubuntu Gutsy laptop.
sudo apt-get install ghc6 sudo apt-get install libghc6-hgl-dev
Then, copy the following code to a file simple.hs somewhere on the disk. This code is from Chapter 3 of the book.
import Graphics.SOE main0 = runGraphics $ do w <- openWindow "My First Graphics Program" (300, 300) drawInWindow w (text (100, 200) "HelloGraphicsWorld") k <- getKey w closeWindow w
Launch GHC interpreter and load the code into it.
$ ghci ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type : ? for help. Loading package base ... linking ... done. Prelude> :l /path/to/simple.hs [1 of 1] Compiling Main ( /path/to/simple.hs, interpreted ) Ok, modules loaded: Main.
Now, run the application as:
*Main> main0 Loading package X11-1.2.1 ... linking ... done. Loading package HGL-3.1.1 ... linking ... done. *Main>
If everything is set up properly, this should show a GUI window with the text ‘HelloGraphicsWorld’ written on it. Pressing any key should dismiss this window.