ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
749 stars 136 forks source link

Search results are different when using the command-line #252

Open unode opened 6 years ago

unode commented 6 years ago

On https://www.haskell.org/hoogle/ (link in the readme) searching m (m a) -> m a shows join as first hit. This matches expectation.

Using the command-line version (hoogle --version -> Hoogle 5.0.17.1, http://hoogle.haskell.org/):

$ hoogle 'm (m a) -> m a'                                               
Darcs.Patch.Witnesses.Unsafe unsafeCoerceP :: a wX wY -> a wB wC
Darcs.Patch.Witnesses.Unsafe unsafeCoercePStart :: a wX1 wY -> a wX2 wY
Darcs.Patch.Witnesses.Unsafe unsafeCoercePEnd :: a wX wY1 -> a wX wY2
Prelude pure :: Applicative f => a -> f a
Control.Applicative pure :: Applicative f => a -> f a
Diagrams.Prelude pure :: Applicative f => a -> f a
CorePrelude pure :: Applicative f => a -> f a
Foundation pure :: Applicative f => a -> f a
CLaSH.Signal signal :: Applicative f => a -> f a
CLaSH.Signal.Internal signal :: Applicative f => a -> f a
-- plus more results not shown, pass --count=20 to see more

Similar results were seen in lambdabot and an entirely different selection on hoogle.haskell.org and stackage.

However, prefixing the search with Monad m => produces saner results:

$ hoogle 'Monad m => m (m a) -> m a' 
Control.Monad join :: (Monad m) => m (m a) -> m a
Streaming join :: Monad m => m (m a) -> m a
Haxl.Prelude join :: Monad m => m (m a) -> m a
Intro join :: Monad m => m (m a) -> m a
Codec.Xlsx.Util.Tabular.Imports join :: Monad m => m (m a) -> m a
Control.Monad.HT repeat :: (Monad m) => m a -> m [a]
Control.Monad.Tools repeatM :: Monad m => m a -> m [a]
Control.Monad.Loops untilJust :: Monad m => m (Maybe a) -> m a
Data.Constraint.Unsafe unsafeApplicative :: forall m a . Monad m => (Applicative m => m a) -> m a
Data.Edison.Seq.ListSeq ltailM :: (Monad rm) => [a] -> rm [a]
-- plus more results not shown, pass --count=20 to see more

Is there any specific syntax that makes the command-line behave more like the web version of hoogle on haskell.org and doesn't require prefixing with Monad m =>?

ndmitchell commented 6 years ago

Hoogle at http://haskell.org/hoogle is version 4 of Hoogle, while the command line you install and https://hoogle.haskell.org are both version 5. Version 5 is worse at type search, for the moment, but that's being tracked e.g. https://github.com/ndmitchell/hoogle/issues/218