Skip to content

Reliably exercise the upper bound of your cabal dependencies

License

Notifications You must be signed in to change notification settings

nomeata/cabal-force-upper-bound

Repository files navigation

cabal-force-upper-bound

What?

This tool parses a .cabal file and returns a set of Cabal constraints (either as command line flags or cabal.project.local stanzas) that constrain your dependencies to the latest major version still allowed your package.

It is a prototype for a feature that feasibly could be part of cabal itself, see haskell/cabal#8387.

Why?

This is necessary if your want your CI system to reliably assess PRs that extend the upper bound, as otherwise cabal may choose a lower version and a passing CI would be misleading.

How?

$ cabal-force-upper-bound --help
Synthesize constraints to force testing the upper bound of cabal dependencies

Usage: cabal-force-upper-bound [--cabal-project] [--allow-newer] CABALFILE

Available options:
  -h,--help                Show this help text
  --cabal-project          create cabal.project.local syntax
  --allow-newer            also create --allow-newer flags
  CABALFILE                cabal file to read (.cabal)

Generating command line flags from the cabal file:

$ cabal-force-upper-bound *.cabal
"--constraint=Cabal-syntax ^>=3.10" "--constraint=base ^>=4.18" "--constraint=bytestring ^>=0.11" "--constraint=containers ^>=0.6" "--constraint=optparse-applicative ^>=0.18" "--constraint=pretty ^>=1.1" "--constraint=text ^>=2.0"

Generating cabal.project stanzas (and also enabling the allow-newer flag):

$./ cabal-force-upper-bound -- --cabal-project --allow-newer *.cabal
constraints: Cabal-syntax ^>=3.10
constraints: base ^>=4.18
constraints: bytestring ^>=0.11
constraints: containers ^>=0.6
constraints: optparse-applicative ^>=0.18
constraints: pretty ^>=1.1
constraints: text ^>=2.0
allow-newer: Cabal-syntax
allow-newer: base
allow-newer: bytestring
allow-newer: containers
allow-newer: optparse-applicative
allow-newer: pretty
allow-newer: text

What else?

This goes well with

Contact

This action was created by Joachim Breitner mail@joachim-breitner.de, initially, during MuniHac 2023.