The packunused package

[ Tags: bsd3, distribution, program ] [ Propose Tags ]

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

Experimental support for stack:

stack setup --upgrade-cabal  # necessary only when stack's global Cabal installation is out of date
stack clean
stack build --ghc-options '-ddump-minimal-imports -O0'

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-


Versions,,,,,,, 0.1.2
Change log
Dependencies base (>=4.5 && <4.10), Cabal (==1.24.*), directory (>=1.1 && <1.4), filepath (>=1.3 && <1.5), haskell-src-exts (>=1.18.2 && <1.20), optparse-applicative (>=0.8 && <0.14), process (>=1.1 && <1.7), split (==0.2.*) [details]
License BSD3
Copyright © 2014 Herbert Valerio Riedel
Author Herbert Valerio Riedel
Maintainer Herbert Valerio Riedel <>
Category Distribution
Home page
Bug tracker
Source repository head: git clone
Uploaded Fri May 5 16:38:49 UTC 2017 by HerbertValerioRiedel
Updated Sat Jun 3 11:13:25 UTC 2017 by HerbertValerioRiedel to revision 1
Distributions LTSHaskell:0.1.2, NixOS:0.1.2
Executables packunused
Downloads 3244 total (14 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-05-05 [all 2 reports]
Hackage Matrix CI


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees