[Haskell] Replacing and improving pattern guards with PMC syntax

kahl at cas.mcmaster.ca kahl at cas.mcmaster.ca
Mon Oct 2 07:59:39 EDT 2006


Brandon Moore <brandonm at yahoo-inc.com> wrote in his answer to my PMC syntax
proposal:
 > 
 > Maybe the '\' could be reiterated to introduce the layout group:
 > 
 > take' = \
 > 0 _ -> []
 > n \[] -> []
 > (x:x) -> x : take (pred n) xs

Definitely not, since the lambda gets us back into expressions,
destroying the fall-through properties of matchings.
(In this particular case this is no problem,
 but in general it would destroy fall-through.)

 > 
 > > alt -> match exp with alts
 > Maybe reuse "case", unless a new keyword is needed to avoid confusion.

We definitely need this construct to produce a matching (or ``alt'').
If we use ``case'' here, then case expressions don't exist anymore.


Wolfram



More information about the Haskell-prime mailing list