MyNixOS website logo
Description

Project statistics and definition analysis.

Please see the README on GitHub at https://github.com/aaronallen8455/inventory#readme

Inventory

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

Cabal

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

Stack

Add this to your stack.yaml file:

ghc-options:
  "$locals": -fwrite-ide-info
             -hiedir=.hie

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.

Examples

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

Definition counts

Most used definitions

Matching type signatures

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.
Metadata

Version

0.1.0.4

Executables (1)

  • bin/inventory

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows