[Haskell-cafe] if-then without -else?

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Mon Jul 9 17:20:11 UTC 2018

Dear Cafe,

a student in my class detected
this inconsistency in the design of Haskell:

> Why require that each "if-then" has an "else"
> while still allowing incomplete sets of patterns?
> We could define "if p then a"
> by translating to "case p of { True -> a }"

I think that "but then we'd have the dangling-else problem"
is not a good answer because this is really about semantics,
not surface syntax.

For reference, Scheme has short-if, see
(value is "unspecified" if condition is false)
and Common LISP does as well
(value is "nil")

Was this considered at some point in Haskell's design process?
There is Section 5.2 on pattern matching in
http://haskell.cs.yale.edu/wp-content/uploads/2011/02/history.pdf (*)
but it does not mention if-then(-else).

- J.W.

(*) can we please add this to https://www.haskell.org/documentation
Upvote this: https://github.com/haskell-infra/hl/issues/86

More information about the Haskell-Cafe mailing list