The Haskell Cabal | Overview

Cabal: Common Architecture for Building Applications and Libraries

Introduction

Cabal is a system for building and packaging Haskell libraries and programs. It defines a common interface for package authors and distributors to easily build their applications in a portable way. Cabal is part of a larger infrastructure for distributing, organizing, and cataloging Haskell libraries and programs.

The term cabal can refer to either: cabal-the-spec (.cabal files), cabal-the-library (code that understands .cabal files), or cabal-the-tool (the cabal-install package which provides the cabal被窝里的公息第十三章 executable); usually folks are referring to cabal-the-tool when they say cabal.

Install/Upgrade cabal

To install the cabal executable you can use (if you're using Linux), the Haskell Platform, install the cabal-install package from your distributions package manager (if using Linux or Mac), or download the source or prebuilt binary from the Download page.

If you already have the cabal executable you can upgrade it by running: cabal install Cabal cabal-install

If the above command failed for any reason see the Update Troubleshooting被窝里的公息第十三章 section below.

Sometimes the older installed version is still on the program search $PATH, you can check you're running the latest version with the command below. If it doesn't match the output of the cabal-install command above you'll need to update it.
cabal --version

Quick Start Guide

Start by installing the cabal executable (see the previous section) and the Haskell compiler ghc (see the GHC download docs).

Starting a new project

mkdir myproject && cd myproject
cabal init
cabal run

Documentation

Related Pages

Update Troubleshooting

Before you try anything else, if you already have a new-ish version of cabal you can use the v2/new commands. Try the following: cabal new-install Cabal cabal-install
If this works update the cabal command on your path with the version installed.

ERROR: cabal: The following packages are likely to be broken by the reinstalls: ...
Use --force-reinstalls if you want to install anyway.

This can happen if your package archive gets into a broken state. How to fix this depends on the situation. Sometimes re-running the command with --force-reinstalls works, other times you have to remove your whole package archive and start over again.

被窝里的公息第十三章 Thankfully this doesn't happen very often, if you run into this issue ask a question on StackOverflow.