O'Reilly logo

Real World Haskell by Donald Bruce Stewart, Bryan O'Sullivan, John Goerzen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Package

The Haskell community has built a standard set of tools, named Cabal, that help with building, installing, and distributing software. Cabal organizes software as a package. A package contains one library, and possibly several executable programs.

Writing a Package Description

To do anything with a package, Cabal needs a description of it. This is contained in a text file whose name ends with the suffix .cabal. This file belongs in the top-level directory of your project. It has a simple format, which we’ll describe next.

A Cabal package must have a name. Usually, the name of the package matches the name of the .cabal file. We’ll call our package mypretty, so our file is mypretty.cabal. Often, the directory that contains a .cabal file will have the same name as the package, e.g., mypretty.

A package description begins with a series of global properties, which apply to every library and executable in the package:

Name:          mypretty
Version:       0.1

-- This is a comment.  It stretches to the end of the line.

Package names must be unique. If you create and install a package that has the same name as a package already present on your system, GHC will get very confused.

The global properties include a substantial amount of information that is intended for human readers, not Cabal itself:

Synopsis: My pretty printing library, with JSON support Description: A simple pretty-printing library that illustrates how to develop a Haskell library. Author: Real World Haskell Maintainer: nobody@realworldhaskell.org ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required