Monday, August 04, 2008

Hoogle 4.0 release (beta, command line)

I am pleased to announce Hoogle 4.0, available on Hackage. A couple of things to note:


  • This is a release of the command-line version only. It will have identical searching abilities to the web-based version, which I'm about to write.

  • It currently only searches the same packages as Hoogle 3 (the final release will search more).

  • It currently doesn't support the --info flag as previously described (problems with Haddock, not with Hoogle).



Walkthrough: Installation

If you have cabal-install available, it should be as simple as:


$ cabal update && cabal install hoogle


Otherwise, follow the standard Cabal/Hackage guidelines. Hoogle depends on about 4 packages on Hackage which are not available with a standard GHC install, so these will need to be built.

Walkthrough: A few searches

Here are some example searches. I have used --count=5 to limit the number of results displayed. If you are using a terminal with ANSI escape codes I recommend also passing --color to enable colored output.


$ hoogle map --count=5
Prelude map :: (a -> b) -> [a] -> [b]
Data.ByteString map :: (Word8 -> Word8) -> ByteString -> ByteString
Data.IntMap map :: (a -> b) -> IntMap a -> IntMap b
Data.IntSet map :: (Int -> Int) -> IntSet -> IntSet
Data.List map :: (a -> b) -> [a] -> [b]

$ hoogle "(a -> b) -> [a] -> [b]" --count=5
Prelude map :: (a -> b) -> [a] -> [b]
Data.List map :: (a -> b) -> [a] -> [b]
Control.Parallel.Strategies parMap :: Strategy b -> (a -> b) -> [a] -> [b]
Prelude fmap :: Functor f => (a -> b) -> f a -> f b
Control.Applicative <$> :: Functor f => (a -> b) -> f a -> f b

$ hoogle Data.Map.map --count=5
Data.Map map :: (a -> b) -> Map k a -> Map k b
Data.Map data Map k a
module Data.Map
Data.Map mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
Data.Map mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)

$ hoogle "Functor f => (a -> b) -> f a -> f b" --count=5
Prelude fmap :: Functor f => (a -> b) -> f a -> f b
Control.Applicative <$> :: Functor f => (a -> b) -> f a -> f b
Control.Monad fmap :: Functor f => (a -> b) -> f a -> f b
Control.Monad.Instances fmap :: Functor f => (a -> b) -> f a -> f b
Data.Traversable fmapDefault :: Traversable t => (a -> b) -> t a -> t b


How you can help

I've released a command line version of the search to solicit feedback. I'm interested in all comments, but especially ones of the form:


  • I prefer the command line version of Hoogle 3 because ...

  • When I search for ... I would expect result ... to appear, or to appear above result ...

  • I was hoping for the feature ...

  • It takes too long when I ...



I'm going to be accumulating Hoogle 4 bugs in my bug tracker, or by email (http://www-users.cs.york.ac.uk/~ndm/contact/) - whichever you find more convenient.

Now I'm going to start work on the Web search :-)

6 comments:

Luke Palmer said...

I just played a bit with the command line tool, and had to say: excellent work! The results I got were much closer to what I would expect as compared to Hoogle 3. I also like having it as a command line tool; the web can be slow.

How do I get it to index all the packages I have installed? Can I search within the scope of a single package (say, opengl, to thwart the cryptically organized documentation)? Should I wait a bit for all my questions to be answered by a README somewhere? ;-)

Luke Palmer said...

One rather distressing result:

% hoogle 'Monoid a => [a] -> a'
Data.Monoid mconcat :: Monoid a => [a] -> a

% hoogle 'Monoid m => [m] -> m'
Prelude maximum :: Ord a => [a] -> a

I expect these two queries to give exactly the same results (in particular, mconcat)

Neil Mitchell said...

Luke: Thanks very much for the testing. You can get indexes of all the packages installed, but its undocumented and requires the latest haddock. I'll be polishing this side with documentation and better commands shortly.

As for the bug, woops! It isn't true that alpha renamed searches give the same results, but they should all give mconcat first. I can see why its happening and will have a fix out shortly.

Neil Mitchell said...

Luke: New version released to Hackage which fixes the bug you found. Also a new test case added to the regression suite so it will never happen again. Thanks :-)

benedikt said...

Great work ! Type search results are far better than with hoogle 3. For use in development, it would be very nice if one could tell hoogle to search a certain set of installed packages. I think that's even more interesting than searching all of hackage.

Here are a few suggestions for the type search (4.0.0.2):

hoogle "CInt -> CInt -> CInt"
Data.Generics.Aliases mkT (#4) -- bad
...
Data.Generics.Aliases extB (#4) -- good
Suggestion: the top-5 results should get a rank > #4

hoogle "(b -> c) -> (b -> c') -> (b -> (c, c'))"
No results found
Suggestion: Maybe a bit too much to ask for, but this type matches Control.Arrow.&&&

Neil Mitchell said...

Benedikt: Searching selective packages is already supported, the database just doesn't have the right information in it yet. That's a job for next week, but will be done soon.

Re: CInt -> CInt -> CInt, there was a bug in the searching which triggered mainly if you searched for two arguments the same. Try again with the version just released on Hackage and you should have more success.

Re: (b -> c) -> (b -> c') -> (b -> (c, c')), the function type -> is handled specially, to deal with things like argument reordering etc, and unfortunately that breaks all the searching by class goodies. I'll file a bug, and hopefully attack it at some point.