There are several methods for acquiring and installing software written in Haskell. Ideally, the software you need is packaged by your OS distribution, and just an apt-get, yum or similar command away. The advantages of this are many, you are likely to get a well-tested version that integrates well with the other tools on your system, and if something breaks, chances are there are lots of users in the same situation, increasing the likelihood that it will be fixed. Unfortunately, not all the interesting software is yet packaged, and here’s how to get the software anyway.
Using cabal-install and Hackage
This is probably the easiest approach. You need to install the GHC compiler and the cabal-install tool. If your OS distribution provides the Haskell Platform, installing that should get you all you need. So e.g. to install flowsim on Debian, you could write:
sudo apt-get install ghc cabal-install cabal update cabal install flowsim
This will a) install the requirements1 b) download the list of available software from the Hackage online repository, and c) download, build, and install flowsim and its dependencies, putting the final executables into $HOME/.cabal/bin. Of course, for the next package, step c) is sufficient, as you now already have the prerequisites installed. Just remember to run ‘cabal update’ now and again to keep the package list current.
To install globally (in /usr/local/bin), replace the last line with
cabal install flowsim --global --root-cmd=sudo
If you don’t have root access, get somebody who has to run apt-get for you.
Using cabal-install and darcs
If the package is not on Hackage, or you need the bleeding-edge version, cabal-install helps you with that as well. Typically, you need to download the source code for your package from somewhere, either using darcs
darcs get http://malde.org/~ketil/biohaskell/flowsim
or some other VCS, or by downloading and unpacking a tarball.
You can then enter the resulting directory, and let cabal-install do its thing:
cd flowsim cabal install
Downloading static binaries
Sometimes, statically linked binaries are provided. Unfortunately, Linux’s libc does not really support static linking anymore, and it is very hard to make executables that will run on different Linux distributions. One common problem is getting this error:
clonesim-0.2.6: mkTextEncoding: invalid argument (Invalid argument)
openFile: invalid argument (Invalid argument)
You can work around some of the problems by setting the GCONV_PATH correctly, e.g. on a Red Hat system, run:
before running the static executables, but static binaries should be seen as a last resort.
Using ‘make’ or other foreign build systems
If the software isn’t using cabal (i.e. there’s no .cabal file in the top level directory), it is probably using some conventional build system. In that case, look for files named README or INSTALL, and read those. Or email the author. Or just cabalize the package, and send patches to the maintainer :-)
The bare minimum requirements, that is. You can use apt-get haskell-platform instead, this will pull in a large bundle of stable, useful libraries as well.↩