haskellhoogle

How can I search all packages with hoogle via command line?


I've installed hoogle locally and have run hoogle generate.

If I run hoogle maybeToEither I get:

Data.Either.Utils maybeToEither :: MonadError e m => e -> Maybe a -> m a
Either maybeToEither :: Monoid b => (a -> b) -> Maybe a -> b
Network.Haskoin.Util maybeToEither :: b -> Maybe a -> Either b a

However if I use the web search I get a few more entries: https://hoogle.haskell.org/?hoogle=maybeToEither

Is there a way I can generate the same 'database' locally? Or is there possibly a CLI for searching https://hoogle.haskell.org?

According to https://wiki.haskell.org/Hoogle I should be able to run hoogle data or hoogle data all - but this seems do just do a search (so maybe outdated?).


Solution

  • I tried:

    $ cabal update
    $ cabal install hoogle
    Installed hoogle-5.0.17.2
    $ hoogle generate --download
    $ hoogle maybeToEither
    

    And got the response:

    Data.Either.Utils maybeToEither :: MonadError e m => e -> Maybe a -> m a
    Data.Either.Extra maybeToEither :: a -> Maybe b -> Either a b
    Extra maybeToEither :: a -> Maybe b -> Either a b
    Protolude.Either maybeToEither :: e -> Maybe a -> Either e a
    Agda.Utils.Either maybeToEither :: Maybe a -> Either () a
    Intro maybeToEither :: () => a -> Maybe b -> Either a b
    

    At the moment the web shows 6 entries, because it has merged the Data.Either.Extra and Extra entries into one line as they refer to the same definition. Other than that, they match.

    Note that hoogle generate generates a database based on what you have already downloaded, so if you run hoogle generate every month the result will not change. Adding --download forces Hoogle to download afresh.