[Haskell-cafe] Why does Haskell have the if-then-else syntax?
Jon Fairbairn
jon.fairbairn at cl.cam.ac.uk
Thu Jul 27 05:22:31 EDT 2006
On 2006-07-27 at 01:33EDT Paul Hudak wrote:
> Thanks for asking about this -- it probably should be in the paper. Dan
> Doel's answer is closest to the truth:
>
> I imagine the answer is that having the syntax for it looks nicer/is
> clearer. "if a b c" could be more cryptic than "if a then b else c"
> for some values of a, b and c.
>
> except that there was also the simple desire to conform to convention
> here (I don't recall fewer parentheses being a reason for the choice).
In a sense, it explicitly wasn't: I suggested "if _ then _
else _ fi" -- something I was long used to from Algol68 --
but it was rejected on the ground that there wasn't a
dangling else problem in Haskell. I probably muttered
something about wanting things to be self-bracketing (I've
certainly grumbled inwardly since about having to write "(if
_ then _ else _)¹" in some Haskell contexts), but since I'm
quite slow witted, I expect that the discussion had moved on
by then.
> In considering the alternative, I remember the function "cond" being
> proposed instead of "if", in deference to Scheme and to avoid confusion
> with people's expectations regarding "if".
Did we talk about Dijkstra's "fat bar", or was that a
discussion I had elsewhere?
Jón
[1] which I find ugly, and besides, making all like
constructs self-bracketing would have allowed a saner (to my
mind) layout rule.
--
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
More information about the Haskell-Cafe
mailing list