Changes between Version 6 and Version 7 of ViewPatterns


Ignore:
Timestamp:
Jan 24, 2007 5:53:53 PM (9 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ViewPatterns

    v6 v7  
    6262
    6363where ''expr'' is an arbitrary Haskell expression.   I'll call a pattern
    64 of this form a '''view pattern'''.
     64of this form a '''view pattern'''. 
    6565
    6666From a '''scoping''' point of view, the variables bound by the pattern (''expr'' `->` ''pat'')
     
    7878''t1 `-> Maybe` t2''. Then the pattern ''pat'' must have type ''t2'', and the
    7979whole pattern (''expr'' `->` ''pat'') has type ''t1''.
     80
     81=== Nesting ====
     82
     83View patterns are just an extra syntactic form of pattern, and they nest inside other patterns, and other patterns nest inside them.  So one can write
     84{{{
     85  f (sing -> x, True) = ...
     86  g (Just [sing -> x]) = ...
     87  h (Just [sing -> Just x]) = ...
     88}}}
     89And by the same token, view patterns nest inside each other:
     90{{{
     91  k :: [[a]] -> a
     92  k (sing -> sing -> x) = x
     93}}}
     94This convenient nesting is perhaps the biggest practical
     95difference between view patterns and pattern guards.
     96
    8097
    8198=== The value input feature ===