Home > Software engineering >  Why Haskell has -- as the syntax of comments?
Why Haskell has -- as the syntax of comments?

Time:08-15

Why Haskell has -- as the syntax of comments? I just want to know if there is any interesting stories behind the decision on this comment syntax in the design of Haskell. (That's all. If this kind of question is not intended for Stack Overflow, I'll delete this.)

CodePudding user response:

For historical Haskell design questions, the best reference is Hudak, Hughes, Peyton Jones, and Wadler's "A History of Haskell: Being Lazy With Class" paper. Here's an electronic copy: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/history.pdf

Section 4.6 talks about comments, and has the following interesting note:

Comments provoked much discussion among the committee, and Wadler later formulated a law to describe how effort was allotted to various topics: semantics is discussed half as much as syntax, syntax is discussed half as much as lexical syntax, and lexical syntax is discussed half as much as the syntax of comments. This was an exaggeration: a review of the mail archives shows that well over half of the discussion concerned semantics, and infix operators and layout provoked more discussion than comments. Still, it accurately reflected that committee members held strong views on low-level details.

It goes on to describe the comment syntax, though I don't see any specific reason why -- was chosen. My personal thought is that so you can separate two parts of the program with a complete dashed-line and it'd be syntactically valid, while looking like a regular document that uses a full line as a separator for a similar effect.

There're further comments regarding bird-tracks which fell out-of-fashion so far as I know. At the end, I think it was more or less an arbitrary choice. But as the quote above indicates, apparently there was considerable discussion around it.

  • Related