bgamari / hoogle-index

Easily generate Hoogle indices for installed packages
Other
25 stars 2 forks source link

hoogle-index — Painless local Haddock indexing

hoogle-index is a small utility for generating indicies for local Hoogle installations.

$ cabal install hoogle hoogle-index
$ hoogle-index -i -l   # this will take a couple of minutes
$ hoogle server -l -p 9000
$ firefox http://localhost:9000/

Your Hoogle index now covers all of the packages locally installed.

What it does

First the utility identifies what packages have been installed. We traverse these packages in topological order to ensure that Hoogle can resolve as many references as possible.

For each package, the utility first checks the package's documentation for an existing textbase (a textual description of a package's interface generated by haddock). While these are provided with some packages (e.g. those installed with GHC), in most cases we'll need to generate one. To do this we unpack the package source, configure it, and invoke Haddock. To avoid needing regenerate this file in future runs we also install the resulting textbase in the appropriate spot in ~/.cabal.

With a textbase in hand we can convert this to a Hoogle database. After traversing all installed packages these individual databases are merged.

Sandbox support

hoogle-index has basic support for cabal sandboxes. Simply run hoogle-index within the root directory of your sandbox and invoke hoogle using hoogle-index's hoogle subcommand. For instance,

$ mkdir test
$ cabal sandbox init
$ cabal install acme-missiles
$ hoogle-index -l
$ hoogle-index hoogle launchMissiles
Acme.Missiles launchMissiles :: IO ()
Acme.Missiles.STM launchMissilesSTM :: STM ()

Caveats

At the moment hoogle-index is an unholy combination of using the Cabal library directly and invoking the cabal-install binary. This means that things will break if any of the following conditions do not hold,

Moreover, some older hoogle releases will fail with some Haskell extensions. This has been fixed upstream.

More resources