API for looking-up/retrieving Haddock comments?

Simon Hengel sol at typeful.net
Fri Aug 3 11:25:29 CEST 2012


> I've been wondering if there have been attempts to provide some
> library/API or similiar facility (other than pointing your web-browser
> to the static Haddock HTML report) for looking up Haddock comments
> associated with Haskell symbols?
> 
> As an obvious application: When coding in dynamic languages
> (e.g. Python, Elisp, or GNU R to name a few), I've learned to appreciate
> the ability to lookup up documentation interactively from the
> tab-completing REPL w/o having to "switch context/focus" to different
> application (as I currently do: I have to switch from GHCi to a
> web-browser and first locate the appropriate package/module and then
> find the symbol I'm interested in).


I have the following in my .ghci:

    -- hoogle integration
    :def hoogle \q -> return $ ":! hoogle --color=true --count=15   \"" ++ q ++ "\""
    :def doc    \q -> return $ ":! hoogle --color=true --info       \"" ++ q ++ "\""

Which can be used from GHCi like so:

    Prelude> :doc map
    Searching for: map
    Prelude map :: (a -> b) -> [a] -> [b]

    map f xs is the list obtained by applying f to each element of xs, i.e.,

    > map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
    > map f [x1, x2, ...] == [f x1, f x2, ...] 

    From package base
    map :: (a -> b) -> [a] -> [b]

Have a look at [1].

Cheers,
Simon

[1] http://www.haskell.org/haskellwiki/Hoogle#GHCi_Integration



More information about the Glasgow-haskell-users mailing list