ghc-usage: Print minimal export lists

[ bsd3, development, library, program ] [ Propose Tags ]

A frontend plugin for computing the minimal export list of a module or signature within a package. This can be used in conjunction with Backpack to easily determine the true set of identifiers which are required from a signature, so that the requirement can be pared down to precisely what is required.


[Skip to Readme]

Modules

  • GhcUsage

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1
Dependencies base (>=4.10 && <4.11), containers, ghc (>=8.1 && <8.3), ghc-paths, unix [details]
License BSD-3-Clause
Author Edward Z. Yang
Maintainer ezyang@cs.stanford.edu
Category Development
Bug tracker https://github.com/ezyang/ghc-usage/issues
Source repo head: git clone https://github.com/ezyang/ghc-usage
Uploaded by EdwardYang at 2017-03-11T09:33:17Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables ghc-usage
Downloads 1590 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2017-03-11 [all 3 reports]

Readme for ghc-usage-0.1.0.1

[back to package description]

ghc-usage

ghc-usage is a simple frontend plugin which outputs the minimum export list for every module and signature necessary to compile the package. This is useful for taking a large signature and paring it down to precisely the identifiers you use.

For example, suppose you have:

signature A where
    f :: Int
    g :: Bool
module B where
    h = f

Clearly, only f is actually used. Thus, ghc-usage will output:

signature A (
    f
) where

The benefit of having a reduced signature is that you allow more implementations (because you require fewer function implementations.)

This tool also outputs minimal export lists for modules, which might be useful if you're trying to make modules more abstract/find unnecessary exports. (Though, if this is a library, obviously there might be external clients using these libraries!)

How to use

ghc-usage is only compatible with GHC 8.2 and later.

Install using cabal install ghc-usage, and then run ghc-usage --interactive A B C. If you are working in a Cabal project, you can run cabal repl -w ghc-usage or cabal new-repl -w usage to get the correct command line arguments.

GHC 8.2 is probably not the default ghc executable in your path. In this case, you will need to also pass --with-ghc-pkg=/path/to/ghc-pkg-8.2; otherwise Cabal will complain about a version mismatch.