[Haskell-cafe] Indentation woes

ok ok at cs.otago.ac.nz
Sun Jul 29 19:15:22 EDT 2007

On 27 Jul 2007, at 4:33 pm, anon wrote:

> 2007/7/26, ok <ok at cs.otago.ac.nz>:
>> The Fundamental Law of Indentation is
>>    "If major syntactic unit X is a proper part of major syntactic
>>     unit Y, then every visible character of X is strictly to the
>>     right[%] of the leftmost[%] visible character of Y."
>> [%] If you are using a right-to-left script, switch "left" and
>> "right" in that sentence.
> What makes this a law

Logical necessity.  That is simply what indentation *IS*.
That's what it *means* to indent something to show its structure.

> If you notice a pattern where beginners trip
> against this rule because they don't indent the arms of conditionals
> properly inside do blocks, should strict adherence to this principle
> take precendence over the intuition of prospective users of the
> language?

The beginners I have taught Haskell to over the last five or six
years have made many mistakes, but that particular one has never
been a problem for them.

Mind you, that may be because I teach them "don't use 'do' (yet)".
While they haven't had any problem with 'if' inside 'do', those of
my students who have found 'do' in their textbook and decided to
use it have repeatedly run into enormous semantic problems.  In
	pat <- expr
LOOKS like an assignment, so they mistakenly expect it to ACT like
an assignment.  It seems clear, therefore, that the heart of the
problem is not the indentation rules, but 'do' in and of itself.
Rather than amend the rules, it would be better *for beginners* if
'do' were not in the language at all.

Should strict adherence to an indentation principle take precedence
over "intuition"?  Yes, YES, *YES*, ten thousand times YES.
Your "intuition" is my "hopeless obscurity".

More information about the Haskell-Cafe mailing list