[Haskell-cafe] Bird-style and blank lines

Paulo Tanimoto tanimoto at arizona.edu
Sun Sep 21 15:08:09 EDT 2008


I'm a big fan of literate haskell, especially Bird-style, but there's
one behavior that I find rather annoying: the requirement that code be
preceded and followed by a blank line.

Quoth the Report:
"To capture some cases where one omits an ">" by mistake, it is an
error for a program line to appear adjacent to a non-blank comment
line, where a line is taken as blank if it consists only of

While that is something I do anyway, since it looks better, there are
some cases where it would be nice to relax that.  For example:

1. I see a blog post in literate style, but the author did not provide
a .lhs file, sometimes copying and pasting the text will result in
code being adjacent to the text.  Then I have to fix that manually.

2. It would be nice for prototyping if you could quickly comment out
code just by removing a ">" character, instead of inserting "--".

3. Pandoc, via markdown, is a very interesting alternative to latex.
Right now you can write a block of code like this:

> fact :: Integer -> Integer
> fact 0 = 1
> fact n = n * fact (n-1)

except that that won't work, precisely because you must have a blank
line before and after the code.  Unfortunately, when you go and add
the blank lines, the output will show them.  You may tell me to change
what Pandoc does, but my point is that getting any markup to work with
Bird-style will have this issue.

The only argument I can see for keeping the requirement is what the
report says, but feel free to provide others [1].  However, isn't that
a bit like saying "we will require two semicolons because forgetting a
semicolon is the number one source of mistake for our programmers"?
Besides, I suspect most of us uses an editor with syntax highlighting
(vi, emacs, yi, etc), and then it's immediately obvious you forgot

Would it be hard to change this behavior in GHC?  Is this open for
discussion for Haskell Prime?



[1] I don't think it's that common to add a ">" by accident.

More information about the Haskell-Cafe mailing list