`stack hoogle` command #55

Closed
chrisdone opened this Issue May 24, 2015 · 12 comments

Projects

None yet

5 participants

@chrisdone
Member

I want this! It should:

  1. Run hoogle with the right database according to the stack config in the directory in which it's run (so it's easily ran from a terminal or by IDEs).
  2. Automatically download the hoogle database from stackage.org e.g. https://www.stackage.org/snapshot/lts-2.1/db.hoo for lts-2.1.
  3. Put it in some reasonable place like ~/.stack/hoogle-databases/lts-2.1.hoo.
  4. Or when running inside docker, use the hoogle database provided by the docker.

The last docker point means we probably need to sync up some things.

With this command I could provide some nice Emacs support with a live hoogle search buffer, and I'd basically never have to leave Emacs to open my browser to read docs again. This closes off two big pain points for me: (1) always having to open the browser and leave my editor environment, (2) needing an internet connection to view docs. This will also basically make my whole haskell-docs package redundant which I'll be able to deprecate in favor of stack.

Pinging @manny-fp and @snoyberg for feedback/opinions.

@chrisdone chrisdone self-assigned this May 24, 2015
@chrisdone
Member

Second thoughts, seems hoogle's -d expects a directory. So it'd probably be better as:

~/.stack/hoogle-databases/lts-2.1/lts-2.1.hoo

This has some potential for putting other databases in there, such as ones generated from your local projects, which could be neat for megarepos.

@snoyberg snoyberg modified the milestone: Second release May 25, 2015
@ndmitchell
Contributor

We should probably be careful about doing too much work with Hoogle 4, when I want to push forward on Hoogle 5, which changes most of this stuff quite dramatically. It's a bit of an awkward middle situation though.

@borsboom borsboom modified the milestone: P2: Should, P3: Optional Oct 7, 2015
@snoyberg snoyberg assigned borsboom and unassigned chrisdone Oct 14, 2015
@ndmitchell
Contributor

I've just pushed something to Hoogle about 10 patches before the minimum-viable product, but it's enough to see where the holes are. Given Hoogle HEAD, you can do hoogle generate --local and it will use ghc-pkg to figure out which packages are installed and where there docs are, then hoogle map and it will find map or hoogle server and it will launch a server at localhost which you can search from. Clicking links will still go to the remote docs, but it is based on the local Hoogle info.

When doing that under Stack there are 122 packages, but only 23 have docs (those shipped with GHC), because Stack doesn't include docs by default. To make stack hoogle work reasonably then stack hoogle would have to generate docs for the immediate dependencies of a module (at least), either always as it was going, or when you typed stack hoogle.

@borsboom
Contributor
borsboom commented Nov 1, 2015

Cool! stack build --haddock (aka stack haddock) already generates docs incrementally (i.e. it will build them for dependencies that don't already have them), so doing that implicitly before stack hoogle (with an option to skip for the impatient) would probably work.

@ndmitchell
Contributor

That works as a solution - it's just a shame that you have to reconfigure all the packages and that it's so slow. Also it fails on Windows, but I'm sure that's fixable: #1266.

@borsboom
Contributor
borsboom commented Nov 3, 2015

One thing that will help with this is that we're planning to support settings defaults for build options on the configuration file. That means you could configure Stack to build haddocks for dependencies by default.

It may also be possible to implement just adding haddocks to a dependency without having to rebuild the library. I looked into this a while back and it seemed feasible, but tricky to integrate into the current build plan construction/execution pipeline.

@ndmitchell
Contributor

Given things in their current state, if stack hoogle did:

  • Build Hoogle from https://github.com/ndmitchell/hoogle (easy with #1278)
  • stack haddock (and ideally, if that worked better, see #1317)
  • stack exec -- hoogle generate --local --database=.stack-work/hoogle
  • stack exec -- hoogle $ARGS --database=.stack-work/hoogle

Then we'd have enough that someone could do stack hoogle filter or stack hoogle server and it would work.

@chrisdone
Member

Implemented! Made a document here for anyone who wants to try it out: https://gist.github.com/chrisdone/78c1c1c052a853697cf3b902de086172

@chrisdone chrisdone closed this Jun 27, 2016
@ndmitchell
Contributor

I tried it last night, works nicely. Any chance of a stack hoogle --server which runs stack hoogle -- --server --local? I find that a very nice way to use Hoogle via Stack.

@chrisdone
Member

@ndmitchell That makes sense to me!

@chrisdone
Member

@ndmitchell Made an issue here: #2310

@krisajenkins

Works perfectly for me. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment