[Haskell-cafe] Why does Haskell have the if-then-else syntax?

Mike Gunter m at ryangunter.com
Fri Jul 28 00:32:47 EDT 2006

Thanks for the answer.  (And doubly thanks for giving the answer I
hoped for!)

I propose that ifThenElse and thenElseIf be added to the Prelude for
Haskell'.  While these names are a bit long, I think we want both
functions and these names make the behaviors clear (to me, at least).



Paul Hudak <paul.hudak at yale.edu> writes:

> 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 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