Changes between Version 13 and Version 14 of PatternSynonyms


Ignore:
Timestamp:
Aug 24, 2013 12:30:06 PM (2 years ago)
Author:
cactus
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PatternSynonyms

    v13 v14  
    7070}}}
    7171
    72 Together with ViewPatternsAlternative we can now create patterns that look like regular patterns to match on existing (perhaps abstract) types in new ways.
    73 {{{
    74    pattern Plus1 n = n1 | let n = n1-1, n >= 0
    75 
    76    fac 0 = 0
    77    fac (Plus1 n) = (n+1) * fac n
    78 }}}
    79 
    80 
    81 Note that the right hand side of `Plus1` binds `n1` and `n`, but since only `n` is mentioned on the left hand side it is the only variable that gets bound when `Plus1` is used.
    82 
    83 Another example showing pattern synonyms used as views, with regular ViewPatterns:
     72Together with ViewPatterns we can now create patterns that look like regular patterns to match on existing (perhaps abstract) types in new ways:
    8473
    8574{{{
     
    9079pattern xs :> x = (Seq.viewr -> xs Seq.:> x)
    9180}}}
    92 
    9381
    9482