7

Context: Before stack I stopped using hoogle locally because my index would somehow lose sync with installed packages. If I recall correctly, I had issues with different results in ghci, command line and cabal sandboxes.

Can I leverage stack environment manage my local hoogle databases?

sevo
  • 4,559
  • 1
  • 15
  • 31
  • 1
    Keeping an eye on this [this github issue](https://github.com/commercialhaskell/stack/issues/55), might be useful. From that I'd say the answer today is probably "not yet". – Shaun the Sheep Jan 06 '16 at 19:07
  • 1
    `stack hoogle generate -- --local` worked for me... – mb21 Aug 23 '17 at 08:58

1 Answers1

6

For the Hoogle part I recommend using the latest git version, which will become version 5. To install that, do:

git clone https://github.com/ndmitchell/hoogle.git
cd hoogle
stack init
stack install

Then generate it and use it with:

# generate Haddock docs for all your packages
stack haddock
# generate the Hoogle index
stack exec -- hoogle generate --local --database=.stack-work/hoogle
# perform a search for map
stack exec -- hoogle map --database=.stack-work/hoogle
# start a server at http://127.0.0.1/ to browse docs
stack exec -- hoogle server --local --database=.stack-work/hoogle

To make this work with Cabal instead of Stack, do cabal install initially, set your haddock/hoogle preference in your Cabal config file to True, and remove the stack exec bits.

Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85
  • 1
    This did not work for me. I get a big long list of `Packages not found: aeson ...` – Joe Shanahan Oct 10 '16 at 12:55
  • ^ when trying to use `hoogle generate` – Joe Shanahan Oct 10 '16 at 13:01
  • With stack 1.5.1, hoogle 5.0.13, after rather lengthy haddock phase in a project I got `Packages missing documentation: adjunctions aeson ...` and most packages are not indexed. I would prefer answer that explains what is needed, as tooling is not reliable and needs to be manually corrected. – sevo Aug 23 '17 at 16:17
  • I had to `$ find ./src/ -name '*.hs' -print0 | xargs -r0 stack exec haddock -- --hoogle --package-name MyPackage --package-version 0.1.1.1` to get hoogle docs for the library itself. Simply running `stack exec -- hoogle generate --local` just made it for the dependencies. – unhammer Sep 19 '17 at 10:17
  • That is, `find ./src/ -name '*.hs' -print0 | xargs -r0 stack exec haddock -- --hoogle --package-name MyPackage --package-version 0.1.1.1 && stack exec hoogle -- generate --local && stack exec hoogle -- myQuery` instead of `stack haddock && stack exec -- hoogle generate --local && stack exec -- hoogle myQuery` – unhammer Sep 19 '17 at 10:36