Using Hoogle for Your Project

Posted on 2015-11-26

Hoogle is a fantastic tool that uses Haskell's type system to build a searchable index of types, functions and constants, connecting with Haddock to provide documentation. It can be used to host browsable websites, like the Hackage instance or the Stackage instance, or used for editor integration, like in vim or emacs. Overall pretty great stuff.

But if working on your own project that is not online anywhere yet, setting up a local Hoogle instance is a bit tricky. But not anymore. I wrote a relatively simple shell script that sets up a local instance combining your project and the Stackage snapshot your project is using. It currently is quite naive, and assumes you are using Linux, and generally is a work in progress. But it works on my machine™, so I am releasing it to the general public (the link is to the master branch of my dotfiles, so it gets updated automatically).

Beware: There is no error checking whatsoever, so make sure you have GHC, Stack, Haddock and Hoogle installed and in your $PATH (also curl and awk). It might also eat all of your data. If you change your stack resolver, you need to delete the Stackage Hoogle database yourself to trigger a download of the right one, there is no version checking. Also local documentation paths do not work when using hoogle server. Some of this might get fixed in the future.