Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bgamari/hoogle-index

Easily generate Hoogle indices for installed packages
https://github.com/bgamari/hoogle-index

Last synced: 3 months ago
JSON representation

Easily generate Hoogle indices for installed packages

Awesome Lists containing this project

README

        

# hoogle-index — Painless local Haddock indexing

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

```bash
$ 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,

```bash
$ 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,

* `cabal-install` is compiled against the same `Cabal` version as `hoogle-index`
(`cabal -V` will report the version that `cabal-install` is built against)
* `haddock` is compiled against the GHC version currently in use

Moreover, some older `hoogle` releases will fail with some Haskell extensions.
This has been [fixed upstream](https://github.com/ndmitchell/hoogle/pull/85).

## More resources

* [Hoogle](http://www.haskell.org/haskellwiki/Hoogle)
* [Database generation](http://neilmitchell.blogspot.com/2008/08/hoogle-database-generation.html)