Changes between Version 1 and Version 2 of PatternGuards


Ignore:
Timestamp:
Jan 16, 2006 11:51:22 PM (8 years ago)
Author:
ross@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PatternGuards

    v1 v2  
    66== Brief Explanation == 
    77 
     8The syntax for guards is changed to 
     9 
     10   ''gd''  ->  `|` ''qual'',,1,,`,` ...`,` ''qual'',,n,, 
     11 
     12(Haskell 98 allows only a single, Boolean, guard.) 
     13In pattern guards of the form ''p'' `<-` ''e'', the two sides must have the same type, and if the value if ''e'' does not match ''p'', the guards fails. 
     14 
    815== References == 
    9  * [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#pattern-guards] The GHC Documentation 
     16 * [http://www.haskell.org/onlinereport/exps.html#case Case Expressions] and [http://www.haskell.org/onlinereport/exps.html#case-semantics Formal Semantics of Pattern Matching] in the Haskell 98 Report 
     17 * [http://research.microsoft.com/~simonpj/Haskell/guards.html Simon's original proposal], 1997. 
     18 * [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#pattern-guards Pattern guards] in the GHC User's Guide 
     19 * [http://research.microsoft.com/Users/simonpj/Papers/pat.htm Pattern Guards and Transformational Patterns], Martin Erwig and Simon Peyton Jones, Haskell Workshop, 2000. 
    1020 
    1121== Pros == 
    12  
     22 * avoids awkward `case` constructs in certain situations 
     23 * a relatively small and orthogonal extension 
     24 * the required changes to the Report are clearly laid out in the above paper. 
    1325 
    1426== Cons == 
     27 * the re-use of monadic binding notation from list comprehensions and `do`-notation for pure matching is confusing, but the more rational `=` would create parsing difficulties, e.g. 
     28   {{{ 
     29f p | x = y = z 
     30}}}