The packunused package

[Tags: bsd3, program]

This simple CLI tool allows to find out which of the packages listed as build-depends in a Cabal package description file are redundant.

packunused works by taking advantage of GHC's -ddump-minimal-imports feature which creates .import files for each compiled module containing a minimal set of explicit import declarations. These .import files together with Cabal's generated package configuration meta-data is analyzed by packunused to detect potentially redundant package dependencies.

In order to use packunused you have to configure the package as usual. See the example session below:

 cabal clean
 rm *.imports
 cabal configure -O0 --disable-library-profiling
 cabal build --ghc-option=-ddump-minimal-imports

The -O0 --disable-library-profiling options are just to speed up compilation. In some cases you might want to pass additional options to the configure step, such as --enable-benchmark or --enable-tests.

When run, packunused prints a report to standard output listing its findings for each component built. The following is an example for the packunused package itself, with a redundant dependency added for demonstration on purpose:

 detected package components

  - executable(s): packunused

 (component names suffixed with '*' are not configured to be built)


 The following package dependencies seem redundant:

  - criterion-


Dependenciesbase (>=4.5 && <4.8), Cabal (>=1.14 && <1.21), directory (>=1.1 && <1.3), filepath (==1.3.*), haskell-src-exts (>=1.13 && <1.17), optparse-applicative (>=0.8 && <0.12), split (==0.2.*)
Copyright(c) 2014 Herbert Valerio Riedel
AuthorHerbert Valerio Riedel
MaintainerHerbert Valerio Riedel <>
Home page
Bug tracker
Source repositoryhead: git clone
UploadedSat Nov 22 08:58:17 UTC 2014 by HerbertValerioRiedel
UpdatedSat Nov 22 09:02:52 UTC 2014 by HerbertValerioRiedel to revision 2
Downloads1899 total (129 in last 30 days)
StatusDocs pending
Build status unknown [no reports yet]


Maintainers' corner

For package maintainers and hackage trustees