Changes between Version 11 and Version 12 of ViewPatterns


Ignore:
Timestamp:
Jan 24, 2007 1:47:00 PM (7 years ago)
Author:
malcolm.wallace@…
Comment:

The "sets as lists" example had an incorrect implementation of insert.

Legend:

Unmodified
Added
Removed
Modified
  • ViewPatterns

    v11 v12  
    257257  has :: Eq a => a -> Set a -> Maybe (Set a) 
    258258  has x (S xs) | x `elem` xs = Just (xs \\ x) 
    259                | otherwise   = Nothing 
     259                   | otherwise   = Nothing 
    260260   
    261261  delete :: a -> Set a -> Set a 
     
    265265  insert :: a -> Set a -> Set a 
    266266  insert x s@(has x -> _) = s 
    267   insert x s              = s 
     267  insert x (S xs)         = S (x:xs) 
    268268}}} 
    269269Notice that in the left-hand side `delete x (has x -> s)`, the first `x` is a binding occurrence,