cabal
Build and manage Haskell projects
TLDR
Search and list packages from Hackage
Show information about a package
Download and install a package
Create a new Haskell project in the current directory
Build the project in the current directory
Run tests of the project in the current directory
SYNOPSIS
cabal [global-options] <command> [<args>]
PARAMETERS
--help, -h, -?
Show help summary
--verbose=n, -v n
Set verbosity level (0-3)
--version
Show cabal version
--numeric-version
Show numeric cabal version
--builddir=DIR
Custom build directory
--project-file=FILE
Specify cabal.project file
--dry-run
Don't execute, just show plan
--ignore-project
Ignore cabal.project
--enable-profiling
Build with profiling
--write-ghc-environment-files=always|never|auto
Control GHC environment files
--lib
Build only libraries
--exe
Build only executables
DESCRIPTION
Cabal is the standard build system and package manager for Haskell projects on Linux and other platforms. It manages dependencies, builds executables and libraries, runs tests, and installs packages from the Hackage repository.
Projects are described in a .cabal file specifying metadata, libraries, executables, test suites, and dependencies. A companion Setup.hs file (generated by default) implements the build backend.
Key workflows include: cabal init to create projects, cabal update for package lists, cabal build to compile, cabal install for global/local installs, and cabal test for testing. Newer versions (3.x) introduce project-based builds with cabal.project files for multi-package workspaces, solver improvements, and native dependency solving.
Cabal integrates with GHC and supports flags for optimization, profiling, and cross-compilation. It's widely used but sometimes paired with Stack for reproducible builds. As of 2023, Cabal 3.10+ emphasizes reproducibility and performance.
CAVEATS
Cabal v1 workflows deprecated; use v2-build or later. Sandboxes removed in 3.0+. Requires GHC installed. Solver may need flags for complex deps.
COMMON SUBCOMMANDS
init: Create new project.
build: Compile project.
install: Install package.
update: Update package list.
test: Run tests.
run: Execute main.
repl: Launch GHCi.
INSTALLATION
Install via ghcup install cabal or Haskell Platform. Requires GHC.
HISTORY
Developed 2003-2005 by Duncan Coutts for GHC 6.4. Evolved through versions: v1 (simple builds), v2 (project files, 2018), v3 (new solver, 2020+). Maintained by Haskell.org committee.


