inventory: Project statistics and definition analysis

[ bsd3, library, program, utility ] [ Propose Tags ]
Versions [RSS],,,,
Change log
Dependencies appendmap (>=0.1.5 && <0.2), array (>=0.5.4 && <0.6), base (>=4.7 && <5), bytestring (>=0.10.10), containers (>=0.6.2 && <0.7), directory (>=1.3.6 && <1.4), filepath (>=1.4.2 && <1.5), ghc (>=8.8 && <9.7), ghc-paths (>=0.1.0), inventory, mtl (>=2.2.2 && <2.4) [details]
License BSD-3-Clause
Copyright 2021 Aaron Allen
Author Aaron Allen
Category Utility
Home page
Bug tracker
Source repo head: git clone
Uploaded by aaronallen8455 at 2023-03-18T21:05:46Z
Distributions NixOS:
Executables inventory
Downloads 647 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-18 [all 1 reports]

Readme for inventory-

[back to package description]


This is a utility that provides a variety of statistics about your Haskell project. These include:

  • A list of type signatures that are shared among multiple locally defined functions, enumerating those functions along with their definition sites.
  • Lists of the most used and least used definitions in the project.
  • A breakdown of local definitions, telling you the number of each type of definition as well as how many lines of code they take up.

Using inventory

Install with stack update && stack install inventory or cabal update && cabal install inventory. The version used to compile inventory must be the same as the version used to compile your project. For stack users, this means you may have to stack install from within your project to use the right GHC.

Inventory uses .hie files to gather information about all haskell files in the project. Once you have generated .hie files for your project, execute inventory from your project's root.

How to generate .hie files


Add this to your cabal.project.local file:

package *
  ghc-options: -fwrite-ide-info -hiedir=.hie

Then do a full rebuild of the project:

cabal clean
cabal build all


Add this to your stack.yaml file:

  "$locals": -fwrite-ide-info

Then do a full rebuild:

stack clean
stack build

By default inventory looks for HIE files in the .hie directory. You can override this using the HIE_DIR environment variable: HIE_DIR=path/to/dir inventory.


Here are some excerpts of the output that was produced by running inventory on the stack codebase:

Definition counts

Definiton counts image

Most used definitions

Most used image

Matching type signatures

Equivalent signatures image

The output for matching signatures can be useful for discovering functions that are duplicates of one another. For instance, the packageIdent and packageIdentifier functions in the above output turned out to be duplicates.

Known Issues/Limitations

  • Context such as constraints and foralls do not appear in the printed type signatures for GHC versions less than 9.0.1.
  • Standalone kind signatures are not yet included in definition counts.
  • Does not unfold type synonyms when comparing type signatures.
  • GHC versions less than 8.8.x are not supported.