[Haskell-cafe] Why does Haskell have the if-then-else syntax?
Paul Hudak
paul.hudak at yale.edu
Thu Jul 27 01:33:06 EDT 2006
Mike Gunter wrote:
>I had hoped the "History of Haskell" paper would answer a question
>I've pondered for some time: why does Haskell have the if-then-else
>syntax? The paper doesn't address this. What's the story?
>
>thanks,
>-m
>
>
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 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".
A related issue is why Haskell does not have a "single arm" conditional
-- i.e. an "if-then" form, which would evaluate to bottom (i.e. error)
if the predicate were false. This was actually discussed, but rejected
as a bad idea for a purely functional language.
-Paul
More information about the Haskell-Cafe
mailing list