You are here

Haskell

Printer-friendly versionPrinter-friendly version

Supported Versions

There are usually several versions of the Haskell Compiler available on DICE, though usually only one version of the Haskell Platform. The default (as invoked by the ghc, etc.) will usually match the default provided by our upstream DICE distributions, but others are available using various commands. Here's a summary of installed versions:

Version Command Location Notes
DICE Ubuntu Focal (most teaching machines)
8.10.2 ghc /opt/ghc Default ghc*, cabal, etc.
8.8.x ghc /usr/bin/; /usr/lib Part of the 2014 Haskell Platform
DICE SL7 (most non-teaching servers)
7.10.3 ghc /usr/bin/; /usr/lib no longer installed by default
8.6.x module add ghc somewhere under /opt/ Must be enabled via module; libraries vary.

Optional GHC versions (SL7 only)

These can be installed using the module system. To list available versions:

$ module show ghc

You'll note there can be multiple instances of the same version, due to the way some of our Haskell software is packaged. You can choose the default (usually latest) with a simple

$ module add ghc

or pick a specific version and library set with the full version string:

$ module add ghc/8.4.3+pandoc

In either case you may remove the currently activated version with:

$ module rm ghc

You may add this command to your .brc to override the default version for all of your future shells, or else enable and disable freely using the add/rm commands.

Installing Haskell libraries

Using Cabal

If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require.

To install a package first update the local database with:

$ cabal update

You can list available packages with

$ cabal list

and install them with

$ cabal install <packagename>

If your requested package has unmet dependencies, cabal will automatically try to fill them by downloading and compiling if required. You can see which packages are currently installed with:

$ ghc-pkg list

By default stack installs packages to ~/.cabal and ~/.ghc in your home directory.

For more details see the cabal install page.

Using Stack

The simplest way to install libraries which require a custom version of Haskell itself is by using the Haskell Tool Stack. This will download a full version of the GHC, of your choice:

$ stack setup <ghc version>

and can also be used to install packages much as cabal does (indeed, it uses the Cabal repositories behind the scenes):

$ stack install <package spec(s)>

Stack is an immensely powerful tool and full reading of stack --help, as well as the stack online documentation, is advised.

Stack can also quickly consume vast amounts of space - a simple one-package install can quickly run to multiple gigabytes, so it's worth checking you have sufficient home directory quota, or else installing to scratch space. If you choose scratch space, remember that this is not backed up.

By default stack installs packages to ~/.stack but can involve ~/.cabal and ~/.ghc.

Building from Source Manually

If the above doesn't suit for whatever reason, it's possible to install Haskell in a local directory (or /disk/scratch or /group/...) and configure the package management to use this in preference to the rpm install.

ghc

First download the appropriate binary for ghc, into a temporary directory, untar the tar file, cd into the directory this creates and then run ./configure pointing it at the directory you want to install ghc into:

$ tar jxvf ghc-7.8.3-x86_64-unknown-linux-centos65.tar.bz2 
$ cd ghc-7.8.3/
$ mkdir /disk/scratch/ghc-latest
$ ./configure --prefix /disk/scratch/ghc-latest/

This will set ghc up to install into a series of directories under /disk/scratch/ghc-latest but you can use any directory you have write permissions on. Then run

$ make install

to install the binaries. Finally add the <prefix>/bin directory to your PATH environmental variable by putting

export PATH=<prefix>/bin:$PATH

in your .brc file. For example:

export PATH=/disk/scratch/ghc-latest/bin:$PATH
Last reviewed: 
17/06/2020

System Status

Home dirs (AFS)
Network
Mail
Other services
University services
Scheduled downtime

Choose a topic