41

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?

Gene T
  • 5,156
  • 1
  • 24
  • 24
dan
  • 43,914
  • 47
  • 153
  • 254

1 Answers1

51

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.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • 22
    Specifically, it is a comment about something that follows the comment, whereas `-- ^` describes something that precedes the comment. –  Jan 11 '13 at 02:08