cabal
cabal copied to clipboard
`cabal check`: Warn about "bad" bounds
A few insights into bounds that cabal check could teach the users via some new warnings:
- A lower bound should be inclusive, i.e. of the form
>= version, and not exclusive, i.e.> version. Common blunders could bebase > 4.11when you actually wantbase >= 4.12. Note that versions make a dense space, so there are infinitely many versions that are> 4.11and< 4.12. - An upper bound should be exclusive, i.e., of the form
< version, and not inclusive, i.e.<= version. A blunder I observed in the wild is folks setting e.g.base <= 4.19.1.0when the last published version ofbaseis4.19.1.0. This way, one blocks patch releases that should always be fine according to the PVP. The correct minor bound isbase < 4.19.2. - An upper bound should not have trailing zeros. E.g.
base < 4.20.0.0could be mistaken to mean thatbase-4.19.*is the latest versions that should be accepted. But reallybase-4.20andbase-4.20.0are not excluded by the bound. The correct bound is< 4.20.
I propose that cabal check warn on subexpressions of the version range that are of the form > version or <= version. It should further warn on upper bounds with trailing zeros, i.e. <= version.0...0.
Here is another case of bad upper bounds in the wild: https://hackage.haskell.org/package/concurrent-output-1.10.21/concurrent-output.cabal
build-depends: ...
, process (>= 1.6.0 && < 1.7.0)
, directory (>= 1.2.0 && < 1.4.0)
, transformers (>= 0.3.0 && < 0.7.0)
, exceptions (>= 0.6.0 && < 0.11.0)
, ansi-terminal (>= 0.6.2 && < 1.2.0)