Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could cabal warn about unused package in dependencies?

Tags:

haskell

cabal

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?

like image 233
ДМИТРИЙ МАЛИКОВ Avatar asked May 05 '13 23:05

ДМИТРИЙ МАЛИКОВ


4 Answers

I think the program packunused is what you are looking for.

like image 138
LambdaStaal Avatar answered Oct 18 '22 16:10

LambdaStaal


There are some options:

  • For GHC 8.6 and earlier, Weeder version 1 by Neil Mitchell can find unused dependencies.
  • For GHC 8.10 and later, there is a warning GHC may emit 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.

like image 29
Ignat Insarov Avatar answered Oct 18 '22 16:10

Ignat Insarov


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.

like image 24
Gabriel Riba Avatar answered Oct 18 '22 17:10

Gabriel Riba


There is yet another tool:

https://github.com/ndmitchell/weeder https://hackage.haskell.org/package/weeder

It's not yet on Stackage though

like image 38
nponeccop Avatar answered Oct 18 '22 17:10

nponeccop