Indentation of If-Then-Else

Henrik Nilsson nhn at Cs.Nott.AC.UK
Mon Oct 23 13:11:29 EDT 2006

 > > Yes, one can argue that they should learn "the right way",
 > > but this is really a very minor detail that many think would
 > > be best if people didn't have to worry about in the first place.
 > There are too much of these minor details.

Yes! Which is why this fix is good, as it means people don't have
to worry about that particular detail!

 > I'm currently concerned with HTML - much more exceptions than rules.
 > This is no fun, and Haskell's syntax will go the same way. Let
 > if-then-else in Haskell for compatibility reasons,

Many would agree that Haskell is getting large and complicated,
but I suspect most people would not blame if-then-else.

It is true, of course, that special syntax for if-then-else is not
needed. But the same can be said for most of Haskell. One could
argue that all you really need is a very small core language. So it
boils down to finding the right balance between convenience,
readability, size of the language, and many other things. And
inevitably, there are going to be very different opinions about what the
right balance is.

Lisp/Scheme are languages with very little special syntax.
I used to use Lisp quite a lot. But I'm not sure the lack of
e.g. predefined control structures made Lisp code that much easier
to write and understand, to be honest. On the contrary, in fact,
as one had to learn libraries of (basic) control-structures on top of
the base language. Nor did it necessarily make the life easier for
people who built the tools, as e.g. Pretty Printers were
expected to identify applications of "special" functions
and lay them out in a different way for the sake of readability.
(And probably just by looking at the name of the function, and
hoping that it meant what it usually meant ...)

But I digress.

 > and try to get rid
 > of it until Haskell-2. But do not endorse its use by new extensions.

I don't think an optional semicolon or two counts as an extension. It
really just is a trivial fix.

Nor do I think leaving things as they are would do anything in itself
to deprecate the use of if-then-else, if that indeed turns out to be
where we'd like to go.

 > Cons are:
 >  The sketched problem with indentation can be solved without touching 
 >  the language.

Well, only if one agrees that a particular style of indenting
if-then-else is necessary in the context of a do, but not elsewhere.

 > The syntax extension is unnecessary, thus complicates all language
 > tools without need.

I'll add that a recommendation for improved error messages has been
suggested as an alternative remedy.


Henrik Nilsson
School of Computer Science and Information Technology
The University of Nottingham
nhn at

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

More information about the Haskell-prime mailing list