In Haddock, the "inline code"¹ markup, @...@
, is the same as the "code block" markup,
@
...
@
How can I write a single-line Haddock comment that consists only of an inline code span, without it being misinterpreted as a block? A comment like
-- |@/code/ span@
renders as the block
code span
instead of the desired inline
code span
The context, in case more examples help, is that I'm writing a data type that represents a BNF grammar, and so I have a number of types that look like the following:
-- |@/term/ ::=@
data Term = Var Name -- ^@/name/@
| Plus Term Term -- ^@/term/ + /term/@
| Print Term -- ^@print /term/@
This example corresponds to the grammar
term ::= name | term + term | print term
and so the grammar is embedded in the Haddock comments. But since Haddock parses those @...@
comments as blocks, the output is unnecessarily tall, and is inconsistent when some lines have extra comment text (e.g., -- ^@double /term/@ – syntax sugar
).
¹ A.k.a. "monospaced" or "typewriter".
i++; // Increment i by 1
style coding. — If you really need BNF, well, provide it as a single plaintext chunk, but not as Haddock inline comments. – leftaroundaboutLet Ident [Binder] (Maybe Term) Term Term
, whichTerm
means what? It helps to see that this production islet /ident/ [/binders/] [: /term/] := /term/ in /term/
. So the comments are half "why" and half "what does this mean?". – Antal Spector-Zabusky