[use Idmaps throughout simplifier
John Meacham <john@repetae.net>**20060409080702] hunk ./E/SSimplify.hs 69
-    f e@(EPi tvr@(TVr { tvrIdent = n, tvrType =  a}) b) = if n `member` fvs || n `Map.member` ags then return (e,delete n fvs ,Map.delete n ags) else return (EPi (tvr { tvrIdent =  0 } ) b,fvs,ags)  where
+    f e@(EPi tvr@(TVr { tvrIdent = n, tvrType =  a}) b) = if n `member` fvs || n `mmember` ags then return (e,delete n fvs ,mdelete n ags) else return (EPi (tvr { tvrIdent =  0 } ) b,fvs,ags)  where
hunk ./E/SSimplify.hs 78
-        return (foldr ELam b' as,foldr delete  (freeVars (map tvrType as) `mappend` fvs) (map tvrIdent as), Map.map inLam $ foldr Map.delete bs (map tvrIdent as))
+        return (foldr ELam b' as,foldr delete  (freeVars (map tvrType as) `mappend` fvs) (map tvrIdent as), fmap inLam $ foldr mdelete bs (map tvrIdent as))
hunk ./E/SSimplify.hs 81
-        return (e,freeVars (t:xs), Map.singleton n Once `andOM` args xs)
+        return (e,freeVars (t:xs), msingleton n Once `andOM` args xs)
hunk ./E/SSimplify.hs 106
-            finalS = Map.union (Map.fromList [(n,LoopBreaker) | (TVr { tvrIdent = n },_) <- lb ]) $   foldl andOM se ([ s | (_,(_,_,s)) <- ds'' ])
-        tell $ Seq.singleton (Map.fromList [ (t,Map.findWithDefault Unused n (Map.mapWithKey frules finalS)) | (t@(TVr { tvrIdent = n }),_) <- ds'' ])
+            finalS = union (fromList [(n,LoopBreaker) | (TVr { tvrIdent = n },_) <- lb ]) $   foldl andOM se ([ s | (_,(_,_,s)) <- ds'' ])
+        tell $ Seq.singleton (fromList [ (t,Map.findWithDefault Unused n (Map.mapWithKey frules finalS)) | (t@(TVr { tvrIdent = n }),_) <- ds'' ])
hunk ./E/SSimplify.hs 118
-        return (Alt l e',foldr delete (freeVars l `mappend` b) (map tvrIdent $ litBinds l),foldr Map.delete c (map tvrIdent $ litBinds l))
+        return (Alt l e',foldr delete (freeVars l `mappend` b) (map tvrIdent $ litBinds l),foldr mdelete c (map tvrIdent $ litBinds l))
hunk ./E/SSimplify.hs 120
-        ans = Map.fromList [ (i,Many) | Just (EVar (TVr { tvrIdent = i }),_) <- map (\e -> from_unsafeCoerce e `mplus` Just (e,Unknown)) as]
+        ans = fromList [ (i,Many) | Just (EVar (TVr { tvrIdent = i }),_) <- map (\e -> from_unsafeCoerce e `mplus` Just (e,Unknown)) as]
hunk ./E/SSimplify.hs 138
-orMaps ms = Map.map orMany $ foldl (Map.unionWith (++)) mempty (map (Map.map (:[])) ms)
+orMaps ms = fmap orMany $ foldl (Map.unionWith (++)) mempty (map (fmap (:[])) ms)
hunk ./E/SSimplify.hs 149
-    so_boundVars :: Map.Map Int E,
+    so_boundVars :: IdMap E,
hunk ./E/SSimplify.hs 158
-    deriving(Show)
-type Subst = Map.Map Int Range
+    deriving(Show,Eq,Ord)
+type Subst = IdMap Range
+
+type InScope = IdMap Binding
hunk ./E/SSimplify.hs 163
-type InScope = Map.Map Int Binding
hunk ./E/SSimplify.hs 167
+    deriving(Ord,Eq)
hunk ./E/SSimplify.hs 177
-    envInScope :: Map.Map Int Binding,
-    envTypeMap :: Map.Map Int E
+    envInScope :: IdMap Binding,
+    envTypeMap :: IdMap E
hunk ./E/SSimplify.hs 184
-    tm = Map.map g s
+    tm = fmap g s
hunk ./E/SSimplify.hs 202
-            dsIn'' = runIdentity $ annotateDs mempty (\t nfo -> return $ maybe (Info.delete Many nfo) (flip Info.insert nfo) (Map.lookup t occ')) (\_ -> return) (\_ -> return) dsIn'
+            dsIn'' = runIdentity $ annotateDs mempty (\t nfo -> return $ maybe (Info.delete Many nfo) (flip Info.insert nfo) (mlookup t occ')) (\_ -> return) (\_ -> return) dsIn'
hunk ./E/SSimplify.hs 204
-    initialB = mempty { envInScope =  Map.map (\e -> isBoundTo Many e) (so_boundVars sopts) }
-    initialB' = mempty { envInScope =  Map.map (\e -> NotKnown) (so_boundVars sopts) }
+    initialB = mempty { envInScope =  fmap (\e -> isBoundTo Many e) (so_boundVars sopts) }
+    initialB' = mempty { envInScope =  fmap (\e -> NotKnown) (so_boundVars sopts) }
hunk ./E/SSimplify.hs 223
-        case Map.lookup (tvrIdent v) sub of
+        case mlookup (tvrIdent v) sub of
hunk ./E/SSimplify.hs 266
-        e' <- f e (Map.insert (tvrIdent v) (Done $ EVar v') sub) (envInScope_u (Map.insert (tvrIdent v') NotKnown) inb)
+        e' <- f e (minsert (tvrIdent v) (Done $ EVar v') sub) (envInScope_u (minsert (tvrIdent v') NotKnown) inb)
hunk ./E/SSimplify.hs 286
-                w rs (Map.insert t (Susp e sub) sub) inb ds
+                w rs (minsert t (Susp e sub) sub) inb ds
hunk ./E/SSimplify.hs 292
-                        w rs (Map.insert t (Done e') sub) (envInScope_u (Map.insert (tvrIdent t') (isBoundTo n e')) inb) ((t',e'):ds)
+                        w rs (minsert t (Done e') sub) (envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) ((t',e'):ds)
hunk ./E/SSimplify.hs 294
-                    False -> w rs sub (if n /= LoopBreaker then (envInScope_u (Map.insert (tvrIdent t') (isBoundTo n e')) inb) else inb) ((t',e'):ds)
+                    False -> w rs sub (if n /= LoopBreaker then (envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) else inb) ((t',e'):ds)
hunk ./E/SSimplify.hs 299
-            sub'' = {- Map.fromList [ (t,Susp e sub'') | (t,Once,_,e) <- s'] `Map.union`-} (Map.fromList [ (t,Done (EVar t'))  | (t,n,t',_) <- s', n /= Once]) `Map.union` sub
-        (ds',sub',inb') <- w s' sub'' (envInScope_u (Map.fromList [ (tvrIdent t',NotKnown) | (_,n,t',_) <- s', n /= Once] `Map.union`) inb) []
+            sub'' = {- Map.fromList [ (t,Susp e sub'') | (t,Once,_,e) <- s'] `Map.union`-} (fromList [ (t,Done (EVar t'))  | (t,n,t',_) <- s', n /= Once]) `union` sub
+        (ds',sub',inb') <- w s' sub'' (envInScope_u (fromList [ (tvrIdent t',NotKnown) | (_,n,t',_) <- s', n /= Once] `union`) inb) []
hunk ./E/SSimplify.hs 336
-        let t'' = substMap'' (Map.map (\ IsBoundTo { bindingE = e } -> e) $ Map.filter isIsBoundTo (envInScope inb)) t'
+        let t'' = substMap'' (fmap (\ IsBoundTo { bindingE = e } -> e) $ mfilter isIsBoundTo (envInScope inb)) t'
hunk ./E/SSimplify.hs 354
-    doCase (EVar v) t b as d sub inb |  Just IsBoundTo { bindingE = ELit l } <- Map.lookup (tvrIdent v) (envInScope inb)  = doConstCase l t  b as d sub inb
+    doCase (EVar v) t b as d sub inb |  Just IsBoundTo { bindingE = ELit l } <- mlookup (tvrIdent v) (envInScope inb)  = doConstCase l t  b as d sub inb
hunk ./E/SSimplify.hs 357
-    doCase (EVar v) t b as d sub inb | Just IsBoundTo { bindingE = e } <- Map.lookup (tvrIdent v) (envInScope inb) , isBottom e = do
+    doCase (EVar v) t b as d sub inb | Just IsBoundTo { bindingE = e } <- mlookup (tvrIdent v) (envInScope inb) , isBottom e = do
hunk ./E/SSimplify.hs 365
-                e' <- doCase e t b' as' d' sub (envInScope_u (Map.fromList [ (n,NotKnown) | TVr { tvrIdent = n } <- litBinds l ] `Map.union`) inb)
+                e' <- doCase e t b' as' d' sub (envInScope_u (fromList [ (n,NotKnown) | TVr { tvrIdent = n } <- litBinds l ] `union`) inb)
hunk ./E/SSimplify.hs 368
-            g x = doCase x t b' as' d' sub (envInScope_u (Map.insert (tvrIdent b) NotKnown) inb)
+            g x = doCase x t b' as' d' sub (envInScope_u (minsert (tvrIdent b) NotKnown) inb)
hunk ./E/SSimplify.hs 401
-        d' <- f d (Map.insert (tvrIdent b) (Done (EVar b')) sub) (envInScope_u  (Map.insert (tvrIdent b') (isBoundTo Many e)) inb)
+        d' <- f d (minsert (tvrIdent b) (Done (EVar b')) sub) (envInScope_u  (minsert (tvrIdent b') (isBoundTo Many e)) inb)
hunk ./E/SSimplify.hs 406
-        f d (Map.insert (tvrIdent b) (Susp e sub) sub) inb
-    doCase (EVar v) _ b [] (Just d) sub inb | Just (NotAmong _) <-  Map.lookup (tvrIdent v) (envInScope inb)  = do
+        f d (minsert (tvrIdent b) (Susp e sub) sub) inb
+    doCase (EVar v) _ b [] (Just d) sub inb | Just (NotAmong _) <-  mlookup (tvrIdent v) (envInScope inb)  = do
hunk ./E/SSimplify.hs 409
-        d' <- f d (Map.insert (tvrIdent b) (Done (EVar v)) sub) inb
+        d' <- f d (minsert (tvrIdent b) (Done (EVar v)) sub) inb
hunk ./E/SSimplify.hs 416
-        let dd e' = f e' (Map.insert (tvrIdent b) (Done $ EVar b') sub) (envInScope_u (newinb `Map.union`) inb) where
+        let dd e' = f e' (minsert (tvrIdent b) (Done $ EVar b') sub) (envInScope_u (newinb `union`) inb) where
hunk ./E/SSimplify.hs 418
-                newinb = Map.fromList [ (n,na) | EVar (TVr { tvrIdent = n }) <- [e,EVar b']]
+                newinb = fromList [ (n,na) | EVar (TVr { tvrIdent = n }) <- [e,EVar b']]
hunk ./E/SSimplify.hs 428
-                    nsub = Map.fromList [ (n,Done (EVar t))  | TVr { tvrIdent = n } <- ns | t <- ns' ]
-                    ninb = Map.fromList [ (n,NotKnown)  | TVr { tvrIdent = n } <- ns' ]
-                e' <- f ae (nsub `Map.union` sub) (envInScope_u (ninb `Map.union`) $ mins e (patToLitEE p') inb)
+                    nsub = fromList [ (n,Done (EVar t))  | TVr { tvrIdent = n } <- ns | t <- ns' ]
+                    ninb = fromList [ (n,NotKnown)  | TVr { tvrIdent = n } <- ns' ]
+                e' <- f ae (nsub `union` sub) (envInScope_u (ninb `union`) $ mins e (patToLitEE p') inb)
hunk ./E/SSimplify.hs 432
-            mins (EVar v) e = envInScope_u (Map.insert (tvrIdent v) (isBoundTo Many e))
+            mins (EVar v) e = envInScope_u (minsert (tvrIdent v) (isBoundTo Many e))
hunk ./E/SSimplify.hs 447
-                e' <- f e (Map.fromList [ (n,Done $ EVar nt) | (_,TVr { tvrIdent = n },nt) <- binds] `Map.union` sub)   (envInScope_u (Map.fromList [ (n,isBoundTo Many e) | (e,_,TVr { tvrIdent = n }) <- binds] `Map.union`) inb)
+                e' <- f e (fromList [ (n,Done $ EVar nt) | (_,TVr { tvrIdent = n },nt) <- binds] `union` sub)   (envInScope_u (fromList [ (n,isBoundTo Many e) | (e,_,TVr { tvrIdent = n }) <- binds] `union`) inb)
hunk ./E/SSimplify.hs 472
-        let lup x = case Map.lookup x (envInScope inb) of
+        let lup x = case mlookup x (envInScope inb) of
hunk ./E/SSimplify.hs 503
-            _ -> case Map.lookup (tvrIdent v) (envInScope inb) of
+            _ -> case mlookup (tvrIdent v) (envInScope inb) of