1. Download the Glasgow Haskell Compiler binary.
2. Decompress the downloaded file and go into the ghc directory.
3. Now you need to configure the ghc binary. You can give the path of installation using the prefix flag.
./configure --prefix=/usr/local/ghc/7.0.3Here I have downloaded v7.0.3. Since I wanted to keep different version of the compiler, I keep folders with version number under the ghc folder. Accordingly, you give the path to the configure script.
4. Install. It is already compiled, because you downloaded the binary.
sudo make install5. Now you need to add the ghc directory to your path so that your bash shell can find it. There are numerous ways to do it. Create a file say "ghc-7.0.3.sh" in "/etc/profile.d"
sudo vim /etc/profile.d/ghc-7.0.3.shLog out and log in. Open your terminal (Ctrl + Alt + T) and type "ghc --version" to ensure ghc is available.
# Add the below contents to the file, save and quit.
# ghc-7.0.3 path
PATH=${PATH}:/usr/local/ghc/7.0.3/bin
6. Now you have a working Haskell Compiler. It is highly recommended to install Haskell-Platform which are a set of libraries for Haskell. For that you go to Haskell-Platform page and download the tar.gz file under the "Build from source" section. Decompress the downloaded file.
7. There are dependency files that you need to have installed before proceeding to compile the Haskell-Platform. So, let us install aptitude, which is a ncurses front-end to APT. Then we shall install 'happy', 'alex' and 'darcs' using 'aptitude' which are haskell libraries.
sudo apt-get install aptitudeNow we need to install C dependencies. To find that we will use a script. In general, the C dependencies are 'libedit-dev', 'libbsd-dev', 'libgmp3-dev', 'zlib1g-dev', 'freeglut3-dev'. You will need to run the below script to find out.
sudo aptitude install happy alex darcs
Let us call the below script 'depcheck'. Put it in 'bin' folder under your home directory. The 'bin' folder is added to you bash path. So bash can find all the scripts inside that folder.
#!/bin/bashSet executable permission for the depcheck script.
# check dependency of a package. The libs with -dev need to be installed
# before building
strace -f -o /tmp/log ./configure
# or make instead of ./configure, if the package doesn't use autoconf
for x in `dpkg -S $(grep open /tmp/log|\
perl -pe 's!.* open\(\"([^\"]*).*!$1!' |\
grep "^/"| sort | uniq|\
grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|\
cut -f1 -d":"| sort | uniq`; \
do \
echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; \
done
chmod +x depcheckNow go to the haskell-platform directory which you decompressed in step 6 and run depcheck. (Just type depcheck and press enter).
It will print out a lot of library names. You need to install all the ones which ends with a '-dev'. So the libraries shown to me are 'libedit-dev', 'libbsd-dev', 'libgmp3-dev', 'zlib1g-dev', 'freeglut3-dev' and 'libglu1-mesa-dev'. (Just in case, if your installation aborted saying that it is missing some library, then you can install them and continue the installation).
sudo apt-get install libedit-dev libbsd-dev libgmp3-dev zlib1g-dev freeglut3-dev libglu1-mesa-dev8. Now that you have got all your dependencies installed, you can proceed with the Haskell-Platform. (You are now in the haskell-platform directory).
./configure --prefix=/usr/local/haskell-platform/2011.2.0.1It will take a while to complete.
make
sudo make install
9. After the successful installation of Haskell-Platform, you need to add the directory to your path. Like in step 5, you create a file say 'haskell-platform-2011.2.0.1.sh' in '/etc/profile.d/' folder.
sudo vim /etc/profile.d/haskell-platform-2011.2.0.1.shLog out and log in.
# Add the following contents to the file, save and quit.
# Haskell-Platform 2011.2.0.1
PATH=${PATH}:/usr/local/haskell-platform/2011.2.0.1/bin
10. All done! Now do a cabal update to get the latest list of all the packages in hackage, which will take a while. Now you can install libraries (eg: hscurses) using cabal.
cabal update
cabal install hscurses #ncurses binding for haskell