
Hello cafe, I was looking into Haskell Report 2010 and notice something in the definition of case statement: https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.1... Apparently an empty alternative within case statement is a plausible production. ('alt' production rule, third option). If I get it correctly, following example shows the empty alternative:
cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False }
What I miss is any ratio behind this. What is the empty alternative good for? Any idea? Franta

Frantisek Farka
Hello cafe,
I was looking into Haskell Report 2010 and notice something in the definition of case statement:
https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.1...
Apparently an empty alternative within case statement is a plausible production. ('alt' production rule, third option).
If I get it correctly, following example shows the empty alternative:
cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False }
What I miss is any ratio behind this. What is the empty alternative good for? Any idea?
Looks like it's to allow "case e of {}". Notice that "lexp" requires an "alts" and "alts" requires at least 1 "alt", so for empty braces to be acceptable there must be an empty alt for them to 'contain'. Cheers, Chris

It is due to being able to mix layout with explicit semicolons.
case x of
a -> b; c -> d;
e -> f ; g -> h;
will add an additional semicolon before the e due to the layout rule.
So in general, semis can always be repeated by allowing empty
expressions in the Haskell grammar when layout is relevant.
John
On Fri, Jun 27, 2014 at 9:00 AM, Chris Warburton
Frantisek Farka
writes: Hello cafe,
I was looking into Haskell Report 2010 and notice something in the definition of case statement:
https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.1...
Apparently an empty alternative within case statement is a plausible production. ('alt' production rule, third option).
If I get it correctly, following example shows the empty alternative:
cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False }
What I miss is any ratio behind this. What is the empty alternative good for? Any idea?
Looks like it's to allow "case e of {}". Notice that "lexp" requires an "alts" and "alts" requires at least 1 "alt", so for empty braces to be acceptable there must be an empty alt for them to 'contain'.
Cheers, Chris _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- John Meacham - http://notanumber.net/
participants (3)
-
Chris Warburton
-
Frantisek Farka
-
John Meacham