Archive for May, 2008

The Haskell School Of Expression: Getting Started on Ubuntu

May 26, 2008 8 comments

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.

First, install GHC and HGL as:

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
   = 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.
/ /_\\/ __  / /___| |
\____/\/ /_/\____/|_|      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.

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.

Categories: tech

Furniture charity

May 9, 2008 Leave a comment

Here is an interesting article (via HN) on how IKEA cons the taxman by posing as a charity. I started reading the book Perfectly Legal, but discontinued after few pages. The IKEA story reminded me to pick it up again – maybe soon after I am done with my current reading list.

Categories: links