Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Hoogle Locally

Tags:

haskell

hoogle

I want to run hoogle on a project of mine. I successfully generated the hoogle database (a file with .hoo extension) from my project. But when I run the server locally, hoogle cannot find any of the functions or types that are defined in my project. It can find some of the prelude functions such as map, but none of the functions that are defined in my project. hoogle dump my-project.hoo dumps the content with no error. I also moved my-project.hoo to ~/.cabal/share/x86_64-osx-ghc-7.8.4/hoogle-4.2.38/databases where all the .hoo files reside. No success again. -verbose switch also does not output any useful information. Any suggestion is appreciated.

Edit:

Thanks to mhuesch's suggestion, I was able to get the search results. Although, the returned results are not linked to the local hackage documents. Something that I couldn't find anywhere on the web is that the hoogle server looks for a file called default.hoo in the current directory.

Edit 2:

If you, like me, have 5000+ databases (i.e., .hoo files) you may get a "too many open files" error when combining them. The trick is simple: run hoogle combine x*.hoo -o=parts/x.hoo for all x='a' ... 'z' and then run hoogle combine *.hoo -o=default.hoo in the parts folder.

Edit 3:

If you want to link your hoogle search results with local hackage documentation, use hoogle convert --doc='absolute-path-to-your-doc' your-package-hoogle-doc.txt default.hoo. I couldn't get relative path working.

like image 1000
Oxy Avatar asked Apr 07 '15 19:04

Oxy


1 Answers

Hoogle searches the current directory (where the command hoogle is run) for a database called 'default.hoo', so if you rename your database to that it should find it.

To add it to the database in your cabal directory, I believe this should work (taken from http://newartisans.com/2012/09/running-a-fully-local-hoogle/):

cd {...path to hoogle databases dir...}
mv default.hoo default.hoo-prev
hoogle combine *.hoo

Edit: (in response on Oxy's edits)

My knowledge of default.hoo comes from here. It seems to doesn't seem to be very well know.

hoobuddy (the above linked project), while cool, doesn't seem to address what you want. I think the key to that is in the help of hoogle data

$ hoogle data --help
...
-l --local[=FILEPATH]  Use local documentation if available
...

I haven't done it myself so I am not sure. The author of this writeup achieved local documentation linking by compiling hoogle from source and adding his local docs directory. I think that you can avoid that by using hoogle data.

like image 134
mhuesch Avatar answered Nov 15 '22 08:11

mhuesch