Question

I see Haskell multi-line comments that sometimes start with {- | instead of just {-.

Does leading with the pipe character inside the comment mean something by convention?

Was it helpful?

Solution

The | at the start of a comment is Haddock syntax that begins a documentation annotation. An example from the Haddock documentation is:

-- |The 'square' function squares an integer.
square :: Int -> Int
square x = x * x

It also goes on to say

The “-- |” syntax begins a documentation annotation, which applies to the following declaration in the source file. Note that the annotation is just a comment in Haskell — it will be ignored by the Haskell compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top