Search code examples
haskellhaddock

How to view Haskell's documentation using Haddock?


For example, how would I view the docs for Data.List.group as I could on hackage?

If I try to use Haddock as:

$ haddock Data.List                                   
<no location info>: error: module ‘Data.List’ is a package module
$ haddock Data.List.group                            
target ‘Data.List.group’ is not a module name or a source file

On the other hand, I know that these html docs exist in my computer under the /usr/local/share/doc directory.

Or am I mistaken and this is not what Haddock does?


Solution

  • The haddock command generates documentation in HTML. To view it you use any web browser by pointing it at the generated file. There should be an index.html file, so you can view it with:

    firefox index.html
    

    Update: If you are using Stack then stack haddock will generate the documentation for your project, and also for all the dependencies.