[Haskell-cafe] Indentation woes

anon individu at gmail.com
Fri Jul 27 14:39:09 EDT 2007

2007/7/27, Steve Schafer <steve at fenestra.com>:
> What exactly are you proposing as an alternative rule? If you're
> suggesting that _any_ line at the same level of indentation as the
> previous line be treated as a continuation of that line, then how would
> one go about indicating that a line is _not_ a continuation of the
> previous line?
I don't see any fundamental reason why this couldn't be handled like
the do-and-if-then-else proposal as Stefan Monnier suggested earlier,
i.e. by adding a few optional semicolons to the grammar. This would
require no change to the layout rule per se.

> On the other hand, if you're suggesting that only certain things be
> recognized as being a continuation of the previous line (e.g., guard
> clauses), then it seems to me that you're replacing a brain-dead simple
> and straightforward rule with one that is inherently more complex and
> thus more likely to cause angst among beginners.
For the most part, beginners can get by using only a superficial
understanding of the layout rule. They only have to worry about the
details when arbitrary restrictions prevent them from writing sensible
code, such as:
> if condition
> then consequent
> else alternative
which works well enough until you try to use it inside a do block.
Amending the rules to allow this usage would arguably decrease "angst
among beginners" with no appreciable impact on the overall complexity
of the language. I see my original example as belonging to this same
category of sensible things that are disallowed for no apparent

> Or are you proposing to get rid of layout altogether and rely on
> punctuation?
> I just can't think of a rule that would be easier to understand (and
> quicker to assimilate) than the current one.
Clearly, eliminating layout altogether would simplify things greatly.
And yet, I assume would do want to keep it around even at the cost of
increased complexity. Why is that I wonder?
What is far less clear however is that adding a few optional
semicolons to the grammar in order to accommodate different
programming styles would impose an incommensurate intellectual burden
on programmers who paradoxically don't mind the occasional detour
through category theory in their "hello world" programs.

More information about the Haskell-Cafe mailing list