6

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.

sclv
  • 38,665
  • 7
  • 99
  • 204
Oxy
  • 323
  • 2
  • 9
  • 3
    AFAIK you have to run `hoogle combine` to get your database in there - sadly all online docs are deadlinked right now and I cannot find the details - I am sure someone will help ASAP – Random Dev Apr 07 '15 at 19:18
  • The [Ganeti](http://code.google.com/p/ganeti/) project has a [repository](http://git.ganeti.org/?p=ganeti-hoogle.git) with a slack role that automates setting up a Hoogle web server from scratch which indexes all the Haskell code of the project. Perhaps it could be helpful to you. (Disclaimer: I'm involved in the project.) – Petr Apr 07 '15 at 20:58

1 Answers1

3

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.

mhuesch
  • 31
  • 5
  • Great! It actually somehow solved the problem. Now, my functions show up in the search results, but they are not linked to local hackage documentation. How can I link to local documents of the packages? – Oxy Apr 07 '15 at 23:26