Reading Docs
Haskell libraries tend to have pretty good docs. We’ve linked to docs via Hackage (https://hackage.haskell.org) previously, but it’s important to know how to find the docs by yourself too. The tool for generating Haskell documentation is called Haddock so sometimes Haskell docs are referred to as haddocks.
Hackage is the Haskell package repository (just like PyPI for Python, Maven Central for Java or NPM for Javascript). In addition to the actual packages, it hosts documentation for them. Most of the modules that we use on this course are in the package called base
. You can browse the docs for the base package at https://hackage.haskell.org/package/base-4.16.4.0/.
When you’re not quite sure where the function you’re looking for is, Hoogle (https://hoogle.haskell.org/) can help. Hoogle is a search engine for Haskell documentation. It is a great resource when you need to check what was the type of foldr
or which packages contain a function named reverse
.
Finally, since this course is using the stack
tool, you can also browse the documentation for the libraries stack has installed for you with the commands
stack haddock --open
stack haddock --open <package>
This has the added benefit of getting exactly the right version of the documentation.
In summary, here are the main ways of reading Haskell library documentation:
- If you know the name of the package you browse the docs via https://hackage.haskell.org/.
- If you know the name of the function you can find it using https://hoogle.haskell.org/.
- If you’re using
stack
you can usestack haddock --open
orstack haddock --open <package>
to open docs in your browser.
You can check your current points from the blue blob in the bottom-right corner of the page.