haskellhoogle

Accessing documentation for a function from Hoogle command line


When searching for a function on the Hoogle website, one sees the documentation associated with it, e.g.:

mod :: a -> a -> a            infixl 7

    integer modulus, satisfying

    (x `div` y)*y + (x `mod` y) == x

Hoogle also exists as a command line executable. As far as I know, it only shows the signature of the function:

~ ❯❯❯ hoogle --info Prelude.mod
Prelude mod :: Integral a => a -> a -> a

From package base
mod :: Integral a => a -> a -> a

Is there a way to get the associated documentation through the command line, as in the online version?


Solution

  • Use the -i option. It is not obvious how to get help for the default command (search); here is how to do it:

    $ hoogle search --help
    Hoogle v4.2.41, (C) Neil Mitchell 2004-2012
    http://haskell.org/hoogle
    
    hoogle [search] [OPTIONS] [QUERY]
      Perform a search
    
    Flags:
      -c --colour --color   Use colored output (requires ANSI terminal)
      -l --link             Give URL's for each result
      -i --info             Give extended information about the first result
      -e --exact            Match names exactly when searching
      -d --databases=DIR    Directories to search for databases
      -s --start=INT        Start displaying results from this point on (1 based)
      -n --count=INT        Maximum number of results to return
      -w --web[=MODE]       Operate as a web tool
      -r --repeat=INT       Run the search multiple times (for benchmarking)
    Common flags:
      -? --help             Display help message
      -V --version          Print version information
         --numeric-version  Print just the version number
      -v --verbose          Loud verbosity
      -q --quiet            Quiet verbosity