Cabal Haskell build tool
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
cabal init --interactive
cabal buildcabal run <exe> -- <args>
cabal testcabal replcabal updatecabal install <exe>
cabal freezeConcepts
Projects
cabal init --interactive
cabal init --non-interactive
cabal init --minimal
cabal checkcabal user-config init
cabal pathBuild
cabal buildcabal build <target>
cabal build allcabal build --enable-tests --enable-benchmarks
cabal build -O2cabal build --ghc-options=-Wall
cabal build -w ghc-<version>
cabal build --only-dependencies
cabal build --enable-profiling
cabal target <pattern>
cabal cleanRun & REPL
cabal runcabal run <exe> -- <args>
cabal run <script>.hs
cabal replcabal repl <target>
cabal repl --enable-tests
cabal repl -b <pkg>
cabal exec -- <cmd>
cabal list-bin <exe>
Test & docs
cabal testcabal test <suite>
cabal test --test-show-details=direct
cabal test --test-options="<args>"
cabal benchcabal haddockcabal haddock-project
Dependencies
cabal updatecabal list <text>
cabal info <pkg>
cabal outdatedcabal freezecabal get <pkg>
cabal build --allow-newer
cabal gen-bounds
cabal build --constraint="<pkg>
==<ver>"
Install
cabal install <exe>
cabal install --installdir=<dir>
cabal install --overwrite-policy=always
cabal install --install-method=copy
cabal install --lib <pkg>
cabal install exe:<name>
Publish
cabal sdistcabal sdist --list-only
cabal upload <tarball>
cabal upload --publish <tarball>
cabal upload --documentation <docs>
Package file
| Stanza | Use |
|---|---|
library |
Reusable code; list exposed-modules |
executable <name> |
Program; needs main-is |
test-suite <name> |
Tests; type: exitcode-stdio-1.0 |
benchmark <name> |
Benchmarks; same form as tests |
common <name> |
Shared fields, pulled in with import: |
| Field | Meaning |
|---|---|
cabal-version |
Spec version, e.g. 3.0 |
build-depends |
Packages with version bounds |
hs-source-dirs |
Where the .hs files live |
default-language |
GHC2021 or Haskell2010 |
ghc-options |
Flags such as -Wall |
other-modules |
Internal, not exported modules |
cabal-version: 3.0name: demoversion: 0.1.0.0build-type: Simplecommon shared default-language: GHC2021 ghc-options: -Wall build-depends: base <5library import: shared hs-source-dirs: src exposed-modules: Demoexecutable demo import: shared hs-source-dirs: app main-is: Main.hs build-depends: demo
cabal.project
packages: .packages: ./*/*.cabal
tests: Trueconstraints: <pkg> ==<ver>
package *with-compiler: ghc-<version>
source-repository-package
cabal configure --enable-tests
--project-file=<file>
Recipes
cabal init --interactivecabal buildcabal run demo -- --helpcabal repl
# cabal.projectpackages: core/ cli/tests: True# thencabal build allcabal test all
# cabal.projectsource-repository-package type: git location: https://github.com/<user>/<repo> tag: <commit>
cabal updatecabal freezegit add cabal.project.freezecabal build --enable-tests && cabal test



