Educate (or prevent) users from making flag-dependent API
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
One instance of this seems to be: https://hackage.haskell.org/package/diagnose
```
if flag(megaparsec-compat)
exposed-modules:
Error.Diagnose.Compat.Megaparsec
```
Since it's not possible to specify required flags on dependencies in `.cabal` files, it's impossible for any package to depend on `Error.Diagnose.Compat.Megaparsec` without causing a build failure with default `cabal build`. A user would have to figure out this configuration and pass `-f+megaparsec-compat` manually on cli or set it in `cabal.project`, which is bad ergonomics for hackage hosted packages (especially in transitive deps).
Instances like this could be detected by `cabal check`, but users may also try to do selective exporting of symbols based on flags (via CPP), which is even harder to statically analyze.
At least, there should be some very clear documentation that this is bad practice in e.g. https://cabal.readthedocs.io/en/3.6/cabal-package.html?highlight=flag#configuration-flags
Contributor guide
Assessment
This issue has not been assessed yet.