Installing Haskell

By Xah Lee. Date: . Last updated: .

Go to and download it.

Once installed, open a terminal, and type


That would start up the Haskell interpreter. Now you can type “1 + 2” to evaluate it. To exit, type “exit”.

Run a Haskell Program

Creat a file “test.hs” and in it put:

fac :: Integer -> Integer
fac 0 = 1
fac n | n > 0 = n * fac (n-1)

main = print (fac 3)

Now, in terminal, cd to the same directory the file is at, start ghci, and type:

:load test.hs
fac 3

You will see it's output is 6.

In ghci, commands to the interpreter are prefixed with a colon “:”. The command “load” loads a file. To see other commands, type “:help”.