Haddock File Format (.haddock)
A Haddock file holds documentation written in Haddock markup, the comment syntax Haskell's own documentation generator reads out of source files to build a module's API reference.
Haddock at a glance#
| Full name | Haddock markup |
|---|---|
| File extension | .haddock |
| Category | Documents |
| Developer | Simon Marlow |
| First released | 2002 |
| Compression | Uncompressed |
| Specification | Haddock User Guide |
| FileFlip support | FileFlip reads and writes this format |
What a .haddock file can hold#
These are the things a Haddock file either supports or does not, and they are what decides whether a conversion keeps everything or quietly drops something.
| Selectable text | Yes |
|---|---|
| Human readable | Yes |
Strengths and limitations of Haddock#
What Haddock does well
- Doc comments (-- | before a declaration, -- ^ after one) live directly next to the code they describe, so documentation and implementation stay in the same file
- Links to another function, type or module are checked against the real identifier, so a rename doesn't leave a dead reference behind
- Ships with GHC and Cabal, so every Haskell package already has the tooling to build docs from it
Where Haddock falls short
- Markup is minimal by design: emphasis, code blocks and identifier links cover most of what it can do, with nothing like a table
- Only means something inside a Haskell source file; there's no standalone document most people write directly in it
- Rendering depends on Haddock parsing the surrounding Haskell syntax correctly, so a doc comment placed oddly can fail silently
Write Haddock markup directly in Haskell source comments so `cabal haddock` can generate the package's API documentation.
Convert Haddock markup to Markdown when the same text needs to appear in a README or a project website outside the generated API docs.
How to open a .haddock file#
A .haddock file opens in the programs below, grouped by the platform you are on. If you would rather not install anything, FileFlip converts Haddock into a format your machine already opens, and it does it in the browser tab rather than on a server.
| Platform | Programs that open it |
|---|---|
| Windows | Any text editor |
| macOS | Any text editor |
| Linux | Any text editor |
| Web | Hackage, FileFlip |
Haddock questions people ask#
What is a .haddock file?
A .haddock file holds text written in Haddock markup, the comment syntax Haskell's documentation generator reads. In practice this markup normally lives inside `-- |` and `-- ^` comments in a .hs source file rather than a standalone file, so a .haddock file usually appears when that text has been extracted or converted on its own.
How do I generate documentation from Haddock comments?
Running `cabal haddock` or `stack haddock` in a Haskell project reads the Haddock comments in its source files and builds an HTML API reference, the same kind of page Hackage hosts for every published package.
What's the difference between -- | and -- ^ in Haddock?
-- | attaches a Haddock doc comment to the declaration that follows it, while -- ^ attaches one to the declaration or argument just before it. The choice is about position: -- | documents forward, -- ^ documents backward.
Converting Haddock files#
Convert Haddock to another format
- Haddock to AsciiDoc
- Haddock to AVIF
- Haddock to BBCode
- Haddock to BibTeX
- Haddock to BMP
- Haddock to BMP2
- Haddock to BMP3
- Haddock to CBZ
- Haddock to Djot
- Haddock to DocBook
- Haddock to DOCX
- Haddock to DokuWiki
- Haddock to EPUB
- Haddock to FB2
- Haddock to GIF
- Haddock to GIF87
- Haddock to HDR
- Haddock to HTML
- Haddock to ICML
- Haddock to ICO
- Haddock to ICON
- Haddock to IPYNB
- Haddock to Jira
- Haddock to JNG
See every Haddock conversion (37 more)
Convert another format to Haddock
- 3FR to Haddock
- ARW to Haddock
- AsciiDoc to Haddock
- AVIF to Haddock
- BibTeX to Haddock
- BMP to Haddock
- BMP2 to Haddock
- BMP3 to Haddock
- CBZ to Haddock
- CR2 to Haddock
- CR3 to Haddock
- Creole to Haddock
- CRW to Haddock
- DCR to Haddock
- Djot to Haddock
- DNG to Haddock
- DocBook to Haddock
- DOCX to Haddock
- DokuWiki to Haddock
- EPUB to Haddock
- ERF to Haddock
- FB2 to Haddock
- GIF to Haddock
- GIF87 to Haddock
See every document conversion (62 more)
Every conversion runs inside your browser. The file is read from your disk, the work happens on your own machine, and nothing is uploaded. How FileFlip works names the engine behind each family and how to verify that for yourself.