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

Dan Doel dan.doel at gmail.com
Thu Jul 27 00:12:40 EDT 2006


On 7/26/06, Donn Cave <donn at drizzle.com> wrote:
> That looks to me like a different way to spell if then else, but maybe
> that's the answer to the question - conceptually, for every "then" there
> really is an "else", however you spell it, and only in a procedural language
> does it make any sense to leave it implicit.  The exception that proves the
> rule is "else return ()" -, e.g.,

...

> Strictly speaking that generalizes to any functional context where a generic
> value can be assigned to the else clause, but there don't tend to be that
> many other such contexts.  Does that answer the question?

I believe his question was why if-then-else is syntax, rather than the
function he gave. Since haskell is non-strict, it doesn't need to be
implemented as syntax (unlike, say, scheme, where it needs to be a
special form/macro to avoid executing both branches).

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.

-- Dan


More information about the Haskell-Cafe mailing list