Reputation: 21990
For given cabal project how could unused dependencies packages be retrieved?
Is there a way to get something like warning during cabal install
process if there is a package mentioned in project dependency and there is no any usage of it, so it could be removed from dependencies?
Upvotes: 24
Views: 2048
Reputation: 4832
There are some options:
-Wunused-packages
) when it sees unnecessary packages in the package database. Since Cabal prepares the package database, any unnecessary package is an unused dependency.Unfortunately, GHC 8.8 is left out.
P. S. There was recently released a program called prune-juice
that should work for GHC 8.8 too.
Upvotes: 8
Reputation: 13677
There is yet another tool:
https://github.com/ndmitchell/weeder https://hackage.haskell.org/package/weeder
It's not yet on Stackage though
Upvotes: 1
Reputation: 6738
cabal-progdeps lists dependencies once the cabal project has been built.
You can check if thay are all used by adding an unused one to your project.
It requires the same Cabal library version used in cabal-install, otherwise it gives errors parsing dist/setup-config.
Upvotes: 2