[project @ 2005-11-29 14:31:59 by ross]
[haskell-directory.git] / Data / IntMap.hs
index e210442..1be0bbe 100644 (file)
@@ -138,6 +138,7 @@ import Data.Int
 import qualified Data.IntSet as IntSet
 import Data.Monoid (Monoid(..))
 import Data.Typeable
+import Data.Foldable (Foldable(foldMap))
 
 {-
 -- just for testing
@@ -216,6 +217,11 @@ instance Ord a => Monoid (IntMap a) where
     mappend = union
     mconcat = unions
 
+instance Foldable IntMap where
+    foldMap f Nil = mempty
+    foldMap f (Tip _k v) = f v
+    foldMap f (Bin _ _ l r) = foldMap f l `mappend` foldMap f r
+
 #if __GLASGOW_HASKELL__
 
 {--------------------------------------------------------------------