Building a Haskell Project

What This Guide Covers #

Language versions and other build-environment specific information are in our reference pages:

The rest of this guide covers configuring Haskell projects on Travis CI. If you’re new to Travis CI please read our Tutorial and build configuration guides first.

Specifying Haskell compiler versions #

The Haskell environment on Travis CI has recent versions of GHC (Glasgow Haskell Compiler) pre-installed. For a detailed list of pre-installed versions, please consult “Build system information” in the build log.

You can specify one or more GHC versions using major.minor notation. Patch level versions (7.6.2 for example) may change any time:

ghc:
  - "7.10"
  - "7.8"
  - "7.6"
  - "8.4.1"

Default Build Script #

The default Haskell build script is:

cabal configure --enable-tests && cabal build && cabal test

Dependency Management #

By default Travis CI uses cabal to manage your project’s dependencies:

cabal install --only-dependencies --enable-tests

Build Matrix #

For Haskell projects, env and ghc can be given as arrays to construct a build matrix.

Multiple Packages in Subdirectories #

If you have multiple packages in subdirectories (each containing a .cabal file, you can specify those directories in an environment variable:

ghc:
  - "7.10"
  - "7.8"
  - "7.6"
env:
  - PACKAGEDIR="some-package"
  - PACKAGEDIR="some-other-package"
before_install: cd ${PACKAGEDIR}

The build matrix is then constructed such that each package is compiled with each version of GHC.

Hackage Deployment #

Travis can automatically upload your package to Hackage. See Hackage Deployment.