Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stack hoogle command (hoogle-5.0) #2301

Merged
merged 4 commits into from
Jun 24, 2016
Merged

Add stack hoogle command (hoogle-5.0) #2301

merged 4 commits into from
Jun 24, 2016

Conversation

chrisdone
Copy link
Member

@chrisdone
Copy link
Member Author

Sample output: https://gist.github.com/chrisdone/1c0cc104646d3c14bfa2dad5be86b463

This command:

  1. auto-installs hoogle, auto-builds haddocks, auto-generates the hoogle database
  2. has a db per snapshot/platform
  3. has a --no-setup command to disable the automatic stuff, which tooling like Emacs will make use of (by providing an appropriate UI for those tasks)
  4. has a --rebuild flag to re-run the auto build/generation step.

This serves as a baseline feature. This is what the community has lacked for years.

Future improvements might be:

  • A config setting to automatically run stack hoogle --rebuild whenever a new package is installed.
  • Something like Intero for Emacs could also run this periodically.

This feature is blocked on Hoogle-5.0 being released, because it will install the latest version of hoogle available. I'm going to try to add some detection for the right version meanwhile.

@ndmitchell
Copy link
Contributor

Give me a couple of hours. I had hoped to do it sooner, but then we accidentally Brexit'd.

@chrisdone
Copy link
Member Author

@ndmitchell yeah, the brexit has been holding my attention today too. No rush. Thanks!

@ndmitchell
Copy link
Contributor

Unblocked! Consider this very definitely a soft release... Hopefully I'll improve it for a 5.0.1 shortly.

@chrisdone
Copy link
Member Author

Great! I'll finish up my branch to test that the version detection works now that it's up on Hackage and merge into master when I'm done. 🎉

@chrisdone
Copy link
Member Author

Works nice!

bash-3.2$ dev_stack hoogle a
Hoogle isn't installed. Automatically installing (use --no-setup to disable) ...
hoogle-5.0: download
hoogle-5.0: configure
hoogle-5.0: build
hoogle-5.0: copy/register
No Hoogle database yet. Automatically building haddocks and hoogle database (use --no-setup to disable) ...
foo-0.1.0.0: unregistering
hoogle-5.0: unregistering
Cabal-1.22.8.0: configure
[...]
Completed 8 action(s).
Updating Haddock index for local packages in
/Users/chris/Work/foo-bar/foo/.stack-work/install/x86_64-osx/lts-6.4/7.10.3/doc/index.html
Updating Haddock index for local packages and dependencies in
/Users/chris/Work/foo-bar/foo/.stack-work/install/x86_64-osx/lts-6.4/7.10.3/doc/all/index.html
Updating Haddock index for snapshot packages in
/Users/chris/.stack/snapshots/x86_64-osx/lts-6.4/7.10.3/doc/index.html
Built docs.
Starting generate
Reading ghc-pkg... 0.10s
[13/128] base... 0.54s
[42/128] ghc... 2.11s
[58/128] http2... 0.07s
[97/128] template-haskell... 0.13s
[121/128] x509-system... 0.00s
[124/128] zlib... 0.03sPackages not found: bytestring-builder present rts transformers-compat
Found 30 warnings when processing items

Reodering items... 0.02s
Writing tags... 0.16s
Writing names... 0.13s
Writing types... 0.55s
Took 8.52s
Generated DB.
newtype A
A :: Integer -> A
abs :: Num a => a -> a
acos :: Floating a => a -> a
acosh :: Floating a => a -> a
all :: Foldable t => (a -> Bool) -> t a -> Bool
and :: Foldable t => t Bool -> Bool
any :: Foldable t => (a -> Bool) -> t a -> Bool
appendFile :: FilePath -> String -> IO ()
asTypeOf :: a -> a -> a
-- plus more results not shown, pass --count=20 to see more

Figure out resolving future versions before we release.
@chrisdone
Copy link
Member Author

Here is the output now for the auto-install (for demonstration purposes I set the min bound to 4.2.34, but it's 5.0 in the committed code):

bash-3.2$ dev_stack hoogle a
Hoogle isn't installed or is too old. Automatically installing (use --no-setup to disable) ...
Populated index cache.
Minimum version is hoogle-4.2.34. Found acceptable hoogle-5.0 in your index, installing it.
hoogle-5.0: configure
hoogle-5.0: build
hoogle-5.0: copy/register
newtype A
A :: Integer -> A
abs :: Num a => a -> a
acos :: Floating a => a -> a
acosh :: Floating a => a -> a
all :: Foldable t => (a -> Bool) -> t a -> Bool
and :: Foldable t => t Bool -> Bool
any :: Foldable t => (a -> Bool) -> t a -> Bool
appendFile :: FilePath -> String -> IO ()
asTypeOf :: a -> a -> a
-- plus more results not shown, pass --count=20 to see more

So it's capable of using a newer version of hoogle, which permits bug fixes and new releases in the hoogle executable without needing new stack releases.

@ndmitchell
Copy link
Contributor

Two questions:

  • What's the time to run hoogle a vs stack hoogle a?
  • Does hoogle server work? With --local I guess is required?

All looks very cool.

@chrisdone
Copy link
Member Author

It adds 200ms of overhead which isn't too great:


bash-3.2$ time /Users/chris/Work/foo-bar/foo/.stack-work/install/x86_64-osx/lts-6.4/7.10.3/bin/hoogle --database .stack-work/hoogle/x86_64-osx/lts-6.4/7.10.3/database.hoo a
newtype A
A :: Integer -> A
abs :: Num a => a -> a
acos :: Floating a => a -> a
acosh :: Floating a => a -> a
all :: Foldable t => (a -> Bool) -> t a -> Bool
and :: Foldable t => t Bool -> Bool
any :: Foldable t => (a -> Bool) -> t a -> Bool
appendFile :: FilePath -> String -> IO ()
asTypeOf :: a -> a -> a
-- plus more results not shown, pass --count=20 to see more

real    0m0.026s
user    0m0.014s
sys 0m0.010s
bash-3.2$ time stack hoogle a
newtype A
A :: Integer -> A
abs :: Num a => a -> a
acos :: Floating a => a -> a
acosh :: Floating a => a -> a
all :: Foldable t => (a -> Bool) -> t a -> Bool
and :: Foldable t => t Bool -> Bool
any :: Foldable t => (a -> Bool) -> t a -> Bool
appendFile :: FilePath -> String -> IO ()
asTypeOf :: a -> a -> a
-- plus more results not shown, pass --count=20 to see more

real    0m0.226s
user    0m0.145s
sys 0m0.081s
bash-3.2$ 

@chrisdone
Copy link
Member Author

But time stack hoogle -- server --local --port 3000 works too!

@mgsloan
Copy link
Contributor

mgsloan commented Jun 24, 2016

LGTM!

@chrisdone chrisdone merged commit ee2457a into master Jun 24, 2016
@chrisdone chrisdone deleted the hoogle5 branch June 24, 2016 21:44
@chrisdone
Copy link
Member Author

🎉

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

Successfully merging this pull request may close these issues.

4 participants