Introduction
This is my first post from the (hopefuly fruitful!) series of blog posts as part of my Haskell SoC project. I will spend a great chunk of my summer hacking away on DarcsDen; in addition, I will document my hardships and successes here. You can follow my progress on my DarcsHub.
This particular post will be about my working environment.
The problem
Hoogle is an amazing tool that usually needs no introduction. Understandably, the online version at haskell.org indexes only so many packages. This means that if I want to use hoogle to search for functions and values in packages like darcs and darcsden, I will have to set up a local copy.
Cabal sandboxing is a relatively recent feature of the Cabal package manager, but I don’t think it is reasonable in this day to install from the source (let alone develop) a Haskell package without using sandboxing.
The problem seems to be that the mentioned tools do not play well together out of the box, and some amount of magic is required. In this note I sketch the solution, on which I’ve eventually arrived after a couple of tries.
Using hoogle inside a Cabal sandbox
The presumed setup: a user is working on a package X using the cabal sandboxes. The source code is located in the directory X
and the path to the cabal sandbox is X/.cabal-sandbox
.
Step 1: Install hoogle inside the sandbox. This is simply a matter of running cabal install hoogle
inside X
. If you want to have a standard database alongside the database for your packages in development, now is the time to do .cabal-sandbox/bin/hoogle data
.
Step 2: Generate haddocks for the packages Y,Z you want to use with hoogle. In my case, I wanted to generate haddocks for darcs and darcsden. This is just a matter of running cabal haddock --hoogle
in the correct directory.
Step 3: Convert haddocks to .hoo files. Run the following commands in X/
:
.cabal-sandbox/bin/hoogle convert /path/to/packageY/dist/doc/html/*/*.txt
You should see something like
Converting /path/to/packageY/dist/doc/html/Y/Y.txt
Converting Y... done
after which the file Y.hoo appears in /path/to/packageY/dist/doc/html/Y/
Step 4: Moving and combining databases. The hoogle database should be stored in .cabal-sandbox/share/*/hoogle-*/databases
. Create such directory, if it’s not present already. Then copy the ‘default’ database to that folder:
cp .cabal-sandbox/hoogle/databases/default.hoo .cabal-sandbox/share/*/hoogle-*/databases
Finally, you can combine your Y.hoo
with the default database.
.cabal-sandbox/bin/hoogle combine /path/to/packageY/dist/doc/html/*/*.hoo .cabal-sandbox/share/*/hoogle-*/databases/default.hoo
mv default.hoo .cabal-sandbox/share/*/hoogle-*/databases/default.hoo
And you are done! You can test your installation
$ .cabal-sandbox/bin/hoogle rOwner
DarcsDen.State.Repo rOwner :: Simple Lens (Repository bp) String
For additional usability, consider adding .cabal-sandbox/bin
to your $PATH.