[add various new and useful routines to Info.Info
John Meacham <john@repetae.net>**20050930030411] hunk ./Info/Info.hs 1
-module Info.Info(T,Info(..),Entry(..),Info.Info.lookup,insertWith,insert,singleton,delete, fetch, extend, empty) where
+module Info.Info(
+    T,
+    Info(..),
+    Entry(..),
+    Info.Info.lookup,
+    insertWith,
+    insert,
+    maybeInsert,
+    singleton,
+    delete,
+    fetch,
+    extend,
+    empty,
+    infoMap,
+    infoMapM
+    ) where
hunk ./Info/Info.hs 85
-{-
-insertWith f x (Info ds) = Info (g ds []) where
-    g [] rs = (toDyn x:rs)
-    g (d:ds) rs
-        | Just y <- fromDynamic d = toDyn (f x y):(ds ++ rs)
-        | otherwise = g ds (d:rs)
--}
hunk ./Info/Info.hs 89
+maybeInsert :: (Show a, Typeable a) => Maybe a -> Info -> Info
+maybeInsert Nothing = id
+maybeInsert (Just x) = insert x
+
hunk ./Info/Info.hs 96
+infoMapM :: (Typeable a, Typeable b, Show b, Monad m) => (a -> m b) -> Info -> m Info
+infoMapM f i = case Info.Info.lookup i of
+    Just x -> do
+        n <- f x
+        return (insert n (delete x i))
+    Nothing -> return i
+
+infoMap :: (Typeable a, Typeable b, Show b) => (a -> b) -> Info ->  Info
+infoMap f i = case Info.Info.lookup i of
+    Just x -> insert (f x) (delete x i)
+    Nothing -> i
+
hunk ./Info/Info.hs 109
-delete x info = error "Info.delete"
+delete x = let typ = createTyp x in  \ (Info mp) -> Info (Map.delete typ mp)