Installing Haskell Platform
Installing the Haskell platform is pretty straight forward. You will have to first download the appropriate setup file from http://hackage.haskell.org/platform/.
Running the setup file will install Haskell compiler and runtime environments in your computer.
After installing the platform you may have to add the <GEC_HOME>/bin directory to the system path.
Running the first program – “Hello World”
Once installing Haskell platform, let’s see how we can run our first “Hello World” program. You can run a program in two ways:
- Using the Haskell interpreter for interactive processing (best option to learning Haskell)
- Compile and executing *.hs files
“Hello World” program using GHC interpreter
- Open terminal / command prompt of your system
- Type ‘ghci’ to get the GHC Interpreter terminal
- Just type in : “Hello, World!” and see what you get!!!
- Another alternative is to us the ‘putStrLn’ statement. Try typing : putStrLn “Hello, World!”
“Hello World” program using GHC compiler
- Create a source file helloworld.hs with content
main = putStrLn "Hello, World!"
- Open terminal and go to the directory where the helloworld.hs file is saved.
- Compile helloworld.hs file using the command. This would create a helloworld.exe file
ghc -o helloworld helloworld.hs
- Now you can run the executable file
Haskell Compilers and Interpreters
The Glasglow Haskell Compiler (GHC) is the most commonly used and the de-facto-standard compiler for Haskell. We have many other important Haskell compilers like:
- Haskell User´s Gofer System (Hugs)
- nhc98
- York Haskell Compiler (YHC)
- HBI and HBC, Chalmers’ Haskell Interpreter and Compiler (Chalmers Haskell-B)
- Utrecht Haskell Compiler (UHC)
- JHC
- LHC
- Yale Haskell
- Disciplined Disciple Compiler (DDC)
The following table tries to compare these compilers.
Comparison-of-Haskell-Compilers-and-Interpreters