Xah Lee, 2005-11-13
Here's how you actually run Haskell code.
Go to http://www.haskell.org/ghc/ and download and install the Glasgow Haskell Compiler for your operating system.
On Mac OS X, this means you download a .dmg file, open it, and run the installer.
Once installed, go to your command line interface (in OS X, it's the Terminal application) and type “ghci”. That would start up the Haskell interpreter. Now you can type “1 + 2” to evaluate it. To exit, type “exit” or Ctrl+d.
Congradualations, you've run a Haskell code!
Creat a file test.hs and in it put:
fac :: Integer -> Integer fac 0 = 1 fac n | n > 0 = n * fac (n-1)
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.
Congradualations, you've run a Haskell program!
In ghci, commands to the interpreter are prefixed with a colon “:”. The command “load” loads a file. To see other commands, type “:help”.
For more detail about using ghci, see the official doc at: http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci.html