If-then-else is a syntactic convenience. Missing cases are usually wrong. We don't want to go out of our way to make it convenient to write wrong code.

On Mon, Jul 9, 2018, 1:20 PM Johannes Waldmann <johannes.waldmann@htwk-leipzig.de> wrote:
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
http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.4.3
(value is "unspecified" if condition is false)
and Common LISP does as well
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node84.html#SECTION001160000000000000000
(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
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.