cabal
Haskell package manager and build system
TLDR
Build project
SYNOPSIS
cabal command [options]
DESCRIPTION
cabal (Common Architecture for Building Applications and Libraries) is the package manager and build system for Haskell. It handles dependency resolution, building, testing, and distributing Haskell packages. Cabal uses Nix-style local builds by default, isolating dependencies per project to avoid conflicts.
PARAMETERS
build
Build projectrun [target]
Build and run executableinstall package
Install packageupdate
Update package indextest
Run test suiterepl
Start GHCi with project loadedclean
Remove build artifactssdist
Create source distributionupload
Upload package to Hackage
CONFIGURATION
~/.cabal/config
Global configuration for package repositories, install directories, and build settings
PROJECT FILE
cabal.cabal example:
name: myproject
version: 0.1.0.0
executable myproject
main-is: Main.hs
build-depends: base >=4.14 && <5
hs-source-dirs: src
default-language: Haskell2010
WORKFLOW
cabal init
# Update package list
cabal update
# Build project
cabal build
# Run executable
cabal run myproject
# Install dependencies
cabal install --only-dependencies
# Run tests
cabal test
# Start REPL
cabal repl
FEATURES
- Dependency resolution
- Sandboxed builds
- Multiple build targets
- Test framework integration
- Benchmarking support
- Documentation generation
- Package publishing to Hackage
CAVEATS
Dependency resolution can be slow. "Cabal hell" (dependency conflicts) historically problematic (improved with Nix-style builds). Large download sizes. Compilation times can be long. GHC version compatibility important.
HISTORY
Cabal was developed for Haskell starting around 2003, with major improvements in Cabal 2.0 (2017) introducing Nix-style local builds.
