We found that cabal repl
will sometimes give false positives for -Wunused-packages
.
@EduardoLR10 worked with me on -Wunused-packages
warnings finding ways to mitigate false positives reported when bringing up the REPL. Some examples are use of the .ghci
configuration file, a cabal.project.local
file and use of the command line to turn off the warning for the REPL only. The fact that cabal repl
can report false positives is, I expect, a bug.
We found another bug where an empty ghc-options
section in a common stanza masked the report of a unused package. Running cabal repl
would unmask this so that subsequently it would be reported by cabal build
(when it wasn’t before). Stack doesn’t report false positives on the warning except when stack repl
is used without using target syntax. In that case stack presents a pick-a-target menu and in that case, I suspect, munges targets somehow to trigger a false positive warning. These problems are annoyances with the REPL but not with the build.
We also encountered false negatives, finding that stack is not always reporting -Werror=unused-packages
. With a ghc-8.10.7 build cabal warns but stack doesn’t.
<no location info>: error: [-Wunused-packages, -Werror=unused-packages]
The following packages were specified via -package or -package-id flags,
but were not needed for compilation:
- lens-4.19.2
Removing lens as a dependency, stack builds the package without complaint showing that the lens dependency was in fact unused.
One thing I take from this, and it is not the only example, is that stack and cabal have their strengths and weaknesses.