[convert E.Subst to use IdMap
John Meacham <john@repetae.net>**20060409065654] hunk ./E/Subst.hs 18
-import List
-import qualified Data.Map as Map
+import List hiding(union,insert,delete)
hunk ./E/Subst.hs 25
+import Util.SetLike as S
+import Util.HasSize
hunk ./E/Subst.hs 41
-subst (TVr { tvrIdent = i }) w e = doSubst False False (Map.insert i (Just w) $ (freeVars w `Map.union` freeVars e))  e
+subst (TVr { tvrIdent = i }) w e = doSubst False False (minsert i (Just w) $ (freeVars w `union` freeVars e))  e
hunk ./E/Subst.hs 51
-subst' (TVr { tvrIdent = (i) }) w e = doSubst True False (Map.insert i (Just w) $ (freeVars w `Map.union` freeVars e)) e
+subst' (TVr { tvrIdent = (i) }) w e = doSubst True False (minsert i (Just w) $ (freeVars w `union` freeVars e)) e
hunk ./E/Subst.hs 66
-substMap :: Map.Map Id E -> E -> E
---substMap im e = doSubst False False (Map.fromList [ (x,Map.lookup x im) | x <- (freeVars e ++ freeVars (Map.elems im)) ]) e
-substMap im e = doSubst False False (Map.map ( (`Map.lookup` im) . tvrIdent) (Map.unions $ (freeVars e :: Map.Map Id TVr):map freeVars (Map.elems im))) e
+substMap :: IdMap E -> E -> E
+substMap im e = doSubst False False (fmap ( (`mlookup` im) . tvrIdent) (unions $ (freeVars e :: IdMap TVr):map freeVars (melems im))) e
hunk ./E/Subst.hs 70
-substMap'' :: Map.Map Id E -> E -> E
-substMap'' im = doSubst False False (Map.map Just im) -- (Map.fromAscList [ (x,Just y) | (x,y) <- Map.toAscList im ]) e
+substMap'' :: IdMap E -> E -> E
+substMap'' im = doSubst False False (fmap Just im)
hunk ./E/Subst.hs 74
-doSubst :: Bool -> Bool -> Map.Map Id (Maybe E) -> E -> E
+doSubst :: Bool -> Bool -> IdMap (Maybe E) -> E -> E
hunk ./E/Subst.hs 76
-    f :: E -> Map.Map Id (Maybe E) -> E
+    f :: E -> IdMap (Maybe E) -> E
hunk ./E/Subst.hs 79
-        case Map.lookup i mp of
+        case mlookup i mp of
hunk ./E/Subst.hs 116
-        e' <- local (Map.insert n Nothing) $ f e
+        e' <- local (minsert n Nothing) $ f e
hunk ./E/Subst.hs 144
-            True -> return (nvr,Map.insert i (Just $ EVar nvr))
-            False -> return (nvr,Map.insert i (Just $ EVar nvr) . Map.insert i' Nothing)
+            True -> return (nvr,minsert i (Just $ EVar nvr))
+            False -> return (nvr,minsert i (Just $ EVar nvr) . minsert i' Nothing)
hunk ./E/Subst.hs 151
-    | i <= 0 || i `Map.member` ss = nv (Map.fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+    | i <= 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
hunk ./E/Subst.hs 155
-nv ss = v (2 * (Map.size ss + 1)) where
-    v n | n `Map.member` ss = v (n + 2)
+nv ss = v (2 * (size ss + 1)) where
+    v n | n `mmember` ss = v (n + 2)
hunk ./E/Subst.hs 159
-nv' ss = v (2 * (Map.size ss + 1)) where
-    v n | (Just Nothing) <- Map.lookup n ss = v (n + 2)
+nv' ss = v (2 * (size ss + 1)) where
+    v n | (Just Nothing) <- mlookup n ss = v (n + 2)
hunk ./E/Subst.hs 172
-typeSubst' :: Map.Map Id E -> Map.Map Id E -> E -> E
-typeSubst' termSub typeSub e | Map.null termSub && Map.null typeSub = e
+typeSubst' :: IdMap E -> IdMap E -> E -> E
+typeSubst' termSub typeSub e | S.null termSub && S.null typeSub = e
hunk ./E/Subst.hs 177
-typeSubst' termSub typeSub e = typeSubst  (Map.map Just termSub `Map.union` Map.map ((`Map.lookup` termSub) . tvrIdent) fvs) typeSub e  where
-    fvs :: Map.Map Id TVr
-    fvs = (freeVars e `Map.union` fvmap termSub `Map.union` fvmap typeSub)
-    fvmap m = Map.unions (map freeVars (Map.elems m))
+typeSubst' termSub typeSub e = typeSubst  (fmap Just termSub `union` fmap ((`mlookup` termSub) . tvrIdent) fvs) typeSub e  where
+    fvs :: IdMap TVr
+    fvs = (freeVars e `union` fvmap termSub `union` fvmap typeSub)
+    fvmap m = unions (map freeVars (melems m))
hunk ./E/Subst.hs 182
-substType t e e' = typeSubst (freeVars e `Map.union` freeVars e') (Map.singleton t e) e'
+substType t e e' = typeSubst (freeVars e `union` freeVars e') (msingleton t e) e'
hunk ./E/Subst.hs 189
-    Map.Map Id (Maybe E)  -- ^ substitution to carry out at term level as well as a list of in-scope variables
-    -> Map.Map Id E       -- ^ substitution to carry out at type level
+    IdMap (Maybe E)  -- ^ substitution to carry out at term level as well as a list of in-scope variables
+    -> IdMap E       -- ^ substitution to carry out at type level
hunk ./E/Subst.hs 192
-typeSubst termSubst typeSubst e | Map.null termSubst && Map.null typeSubst = e
+typeSubst termSubst typeSubst e | S.null termSubst && S.null typeSubst = e
hunk ./E/Subst.hs 194
-    termSubst' = termSubst `Map.union` Map.map (const Nothing) typeSubst
-    f :: E -> (Bool,Map.Map Id (Maybe E),Map.Map Id E) -> E
+    termSubst' = termSubst `union` fmap (const Nothing) typeSubst
+    f :: E -> (Bool,IdMap (Maybe E),IdMap E) -> E
hunk ./E/Subst.hs 198
-        case (wh,Map.lookup i trm, Map.lookup i tp) of
+        case (wh,mlookup i trm, mlookup i tp) of
hunk ./E/Subst.hs 247
-    addMap i (Just e) (b,trm,typ) = (b,Map.insert i (Just e) trm, Map.insert i e typ)
-    addMap i Nothing (b,trm,typ) = (b,Map.insert i Nothing trm, typ)
+    addMap i (Just e) (b,trm,typ) = (b,minsert i (Just e) trm, minsert i e typ)
+    addMap i Nothing (b,trm,typ) = (b,minsert i Nothing trm, typ)