Encourage top-level `build-depends` when it occurs in all branches of a conditional
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
See e.g. https://github.com/jvranish/Lenses/issues/3.
Currently hackage does not allow revision of conditionals, and it does not allow new `build-depends`.
In the situation (1)
```
build-depends: base
, A
if cond
build-depends: B >= 0.1 && < 0.4
else
build-depends: B >= 0.2 && < 0.5
```
the constraints for `B` cannot be revised.
Thus, the better practice is to put a top-level `B` with extra constraints in the conditional (2):
```
build-depends: base
, A
, B >= 0.1 && < 0.5
if cond
build-depends: B < 0.4
else
build-depends: B >= 0.2
```
If `cabal check` would suggest a adding a top-level `build-depends` that appears in all branches, that would help with revisions on hackage.
Of course, this could also be fixed on the hackage side; in case it is fixed there by rejecting packages that could be rewritten from (1) to (2), `cabal check` should also warn about possible complaints by the hackage server.
Contributor guide
Research direction
Start with the cabal check behavior described in this issue and the two conditional build-depends examples. Determine how to detect a dependency present in every conditional branch, then make cabal check report a suggestion for a top-level dependency and verify that the warning covers the Hackage revision concern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100