Haskell Links and Resources

Installing the Haskell Tool Chain

The Haskell compiler we’ll be using in this class is GHC. You’ll also need a tool called cabal for installing Haskell packages (see below) and a tool called Stack for working with Haskell projects.

The easiest way to install these tools varies by platform.

On Mac, use Homebrew. First install Homebrew itself, if you don’t already have it on your system. Then install everything with the following command:

> brew install ghc cabal-install haskell-stack

On Windows, use Chocolatey. First install Chocolatey itself, if you don’t already have it on your system. Then install everything with the following command:

> choco install ghc cabal haskell-stack

On Linux, use whatever package manager is standard on your distribution (e.g. apt on Ubuntu, dnf on Fedora). The cabal package you want is probably called cabal-install and the stack package is probably called haskell-stack. However, make sure that the GHC version installed is at least 8.4.

If you want the latest and greatest on Linux or Mac, you can install GHC/cabal using ghcup and install Stack directly by running the command on their site. Both of these tools install to your home directory, so they don’t pollute your system.

Haskell Packages and Projects

Hackage is the central package archive for the Haskell community. It contains lots of useful libraries, many of which may be useful in your projects. I will also occasionally use libraries from Hackage in my example code.

The easiest way to install packages from Hackage is using the cabal tool, which you should have installed above. First run the following command to download the list of packages on Hackage.

cabal update

Then you can install new packages by running the following command.

cabal install [package-name]

For your project, you may wish to manage packages in a more structured way. For this, check out Stack, which can be used to locally and automatically manage the packages your project depends on. This is useful because it makes it much easier for others to run your project, and because it helps avoid conflicts between incompatible packages that can arise when all packages are installed globally.

Installing Doctest

Doctest is a useful tool for running examples written in the comments of a Haskell file as unit tests. We’ll use this in some Hasklets.

After you’ve installed GHC and cabal, you can install doctest with the following commands:

cabal update
cabal install doctest

You will also need to add the directory that cabal installs its binaries into to your $PATH. Here are my best guesses as to where that will be:

  • Linux and Mac: ~/.cabal/bin
  • Windows: C:\Program Files\Haskell\bin

Haskell Tutorials and Reference Manuals

  • Introduction to Haskell by Brent Yorgey – An excellent, concise introduction to Haskell.

  • Haskell: The Confusing Parts – An FAQ especially for folks coming to Haskell from a C/Java background, which I guess is many of the people in this class.

  • Real World Haskell – O’Reilly’s book-length introduction to Haskell focusing on practical applications. Available for free online.

  • Haskell Wikibook – An easy-to-navigate and thorough resource.

  • A Gentle Introduction to Haskell – Famous for being not-so-gentle, but a really great resource for refining your understanding of Haskell, once you get the basics down.

Haskell Style


Back to course home page