From 2b059b811db03a53e8e0f8ec1a655e507851a995 Mon Sep 17 00:00:00 2001 From: peb Date: Mon, 9 May 2005 08:25:56 +0000 Subject: "Committed_by_peb" --- src/GF/Data/Assoc.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/GF/Data/Assoc.hs') diff --git a/src/GF/Data/Assoc.hs b/src/GF/Data/Assoc.hs index 64ec3bac9..f775319ea 100644 --- a/src/GF/Data/Assoc.hs +++ b/src/GF/Data/Assoc.hs @@ -5,9 +5,9 @@ -- Stability : Stable -- Portability : Haskell 98 -- --- > CVS $Date: 2005/04/12 10:49:45 $ +-- > CVS $Date: 2005/05/09 09:28:44 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.3 $ +-- > CVS $Revision: 1.4 $ -- -- Association lists, or finite maps, -- including sets as maps with result type @()@. @@ -25,6 +25,7 @@ module GF.Data.Assoc ( Assoc, aAssocs, aElems, assocMap, + assocFilter, lookupAssoc, lookupWith, (?), @@ -63,6 +64,9 @@ aElems :: Ord a => Assoc a b -> SList a -- the mapping function can take the key as information assocMap :: Ord a => (a -> b -> b') -> Assoc a b -> Assoc a b' +assocFilter :: Ord a => (b -> Bool) -> Assoc a b -> Assoc a b +assocFilter pred = listAssoc . filter (pred . snd) . aAssocs + -- | monadic lookup function, -- returning failure if the key does not exist lookupAssoc :: (Ord a, Monad m) => Assoc a b -> a -> m b -- cgit v1.2.3