[switch to new type family version of SetLike
John Meacham <john@repetae.net>**20100724094749
 Ignore-this: d96d078c0c6e830a2a976ab3c7692bea
] hunk ./src/DataConstructors.hs 541
-    newDataTable = DataTable (Map.mapWithKey fixupMap $ Map.fromList [ (conName x,procNewTypes x) | x <- ds', conName x `notElem` mkeys primitiveAliases ])
+    newDataTable = DataTable (Map.mapWithKey fixupMap $ Map.fromList [ (conName x,procNewTypes x) | x <- ds', conName x `notElem` keys primitiveAliases ])
hunk ./src/DataConstructors.hs 639
-        existentials = melems $ freeVars (map getType origArgs) S.\\ (freeVars thisTypeArgs :: IdMap TVr)
+        existentials = values $ freeVars (map getType origArgs) S.\\ (freeVars thisTypeArgs :: IdMap TVr)
hunk ./src/E/Annotate.hs 156
-    | isInvalidId i || i `mmember` ss  = newId (size ss) isOkay
+    | isInvalidId i || i `member` ss  = newId (size ss) isOkay
hunk ./src/E/Annotate.hs 158
-    where isOkay i = (i `mnotMember` ss) && (i `notElem` xs)
+    where isOkay i = (i `notMember` ss) && (i `notElem` xs)
hunk ./src/E/Demand.hs 15
-import Data.List hiding(union)
+import Data.List hiding(union,delete)
hunk ./src/E/Demand.hs 190
-demandEnvMinus (DemandEnv m r) x = DemandEnv (mdelete (tvrIdent x) m) r
+demandEnvMinus (DemandEnv m r) x = DemandEnv (delete (tvrIdent x) m) r
hunk ./src/E/Demand.hs 194
-        m = fromList [ (x,lenv x d1 `lub` lenv x d2) | x <- mkeys (m1 `union` m2)]
+        m = fromList [ (x,lenv x d1 `lub` lenv x d2) | x <- keys (m1 `union` m2)]
hunk ./src/E/Demand.hs 196
-        m = fromList [ (x,lenv x d1 `glb` lenv x d2) | x <- mkeys (m1 `union` m2)]
+        m = fromList [ (x,lenv x d1 `glb` lenv x d2) | x <- keys (m1 `union` m2)]
hunk ./src/E/Demand.hs 344
-denvDelete x (DemandEnv m r) = DemandEnv (mdelete (tvrIdent x) m) r
+denvDelete x (DemandEnv m r) = DemandEnv (delete (tvrIdent x) m) r
hunk ./src/E/FreeVars.hs 26
-    freeVars x = melems $ (freeVars x :: IdMap TVr)
+    freeVars x = values $ (freeVars x :: IdMap TVr)
hunk ./src/E/FreeVars.hs 93
-    fv (ELam TVr { tvrIdent = i, tvrType = t} e) = mdelete i $ fv e <> fv t
-    fv (EPi  TVr { tvrIdent = i, tvrType = t} e) = mdelete i $ fv e <> fv t
+    fv (ELam TVr { tvrIdent = i, tvrType = t} e) = delete i $ fv e <> fv t
+    fv (EPi  TVr { tvrIdent = i, tvrType = t} e) = delete i $ fv e <> fv t
hunk ./src/E/FreeVars.hs 101
-    fv ECase { eCaseScrutinee = e, eCaseBind = b, eCaseAlts = as, eCaseDefault = d, eCaseType = ty } = mconcat ( fv e:freeVars (tvrType  b):freeVars ty:(mdelete (tvrIdent b) $ mconcat (freeVars d:map freeVars as)  ):[])
+    fv ECase { eCaseScrutinee = e, eCaseBind = b, eCaseAlts = as, eCaseDefault = d, eCaseType = ty } = mconcat ( fv e:freeVars (tvrType  b):freeVars ty:(delete (tvrIdent b) $ mconcat (freeVars d:map freeVars as)  ):[])
hunk ./src/E/LambdaLift.hs 31
-import Util.SetLike
+import Util.SetLike hiding(Value)
hunk ./src/E/Lint.hs 120
-        fvs = Set.fromList $ melems (freeVars $ snds $ programDs prog :: IdMap TVr)
+        fvs = Set.fromList $ values (freeVars $ snds $ programDs prog :: IdMap TVr)
hunk ./src/E/Main.hs 76
-        (_,orphans) = mpartitionWithKey (\k _ -> k `elem` map tvrIdent newTVrs) rm
+        (_,orphans) = spartition (\ (k,_) -> k `elem` map tvrIdent newTVrs) rm
hunk ./src/E/Main.hs 78
-    let fakeEntry = emptyComb { combRules = map ruleUpdate . concat $ melems orphans }
-        combs =  fakeEntry:[combRules_s (map ruleUpdate $ mfindWithDefault [] (tvrIdent t) rm) (bindComb (t,e))  | (t,e) <- hoEs (hoBuild aho) ]
+    let fakeEntry = emptyComb { combRules = map ruleUpdate . concat $ values orphans }
+        combs =  fakeEntry:[combRules_s (map ruleUpdate $ findWithDefault [] (tvrIdent t) rm) (bindComb (t,e))  | (t,e) <- hoEs (hoBuild aho) ]
hunk ./src/E/Main.hs 83
-        nrules = map ruleUpdate . combRules $ mfindWithDefault emptyComb emptyId choCombinators'
+        nrules = map ruleUpdate . combRules $ findWithDefault emptyComb emptyId choCombinators'
hunk ./src/E/Main.hs 88
-    let finalVarMap = mappend (fromList [(tvrIdent tvr,Just $ EVar tvr) | tvr <- map combHead $ melems choCombs ]) (choVarMap accumho)
-        choCombs = mfilterWithKey (\k _ -> k /= emptyId) choCombinators'
+    let finalVarMap = mappend (fromList [(tvrIdent tvr,Just $ EVar tvr) | tvr <- map combHead $ values choCombs ]) (choVarMap accumho)
+        choCombs = sfilter (\(k,_) -> k /= emptyId) choCombinators'
hunk ./src/E/Main.hs 147
-    let seasoning = freeVars [ rs | (k,rs) <- massocs rules', k `notMember` defined ] `intersection` defined
+    let seasoning = freeVars [ rs | (k,rs) <- toList rules', k `notMember` defined ] `intersection` defined
hunk ./src/E/Rules.hs 75
-    put (Rules mp) = put (concat $ melems mp)
+    put (Rules mp) = put (concat $ values mp)
hunk ./src/E/Rules.hs 96
-printRules ty (Rules rules) = mapM_ (\r -> printRule r >> putChar '\n') [ r | r <- concat $ melems rules, ruleType r == ty ]
+printRules ty (Rules rules) = mapM_ (\r -> printRule r >> putChar '\n') [ r | r <- concat $ values rules, ruleType r == ty ]
hunk ./src/E/Rules.hs 116
-    mappend (Rules x) (Rules y) = Rules $ munionWith (combineRules) x y
+    mappend (Rules x) (Rules y) = Rules $ unionWith combineRules x y
hunk ./src/E/Rules.hs 192
-rsubstMap im e = doSubst False True (fmap ( (`mlookup` im) . tvrIdent) (unions $ (freeVars e :: IdMap TVr):map freeVars (melems im))) e
+rsubstMap im e = doSubst False True (fmap ( (`mlookup` im) . tvrIdent) (unions $ (freeVars e :: IdMap TVr):map freeVars (values im))) e
hunk ./src/E/SSimplify.hs 96
-   deriving(HasSize,SetLike,BuildSet (Id,UseInfo),MapLike Id UseInfo,Show,IsEmpty,Eq,Ord)
+   deriving(HasSize,Collection,Unionize,SetLike,MapLike,Show,IsEmpty,Eq,Ord)
+
+type instance Value OMap = UseInfo
+type instance Key OMap = Id
+type instance Elem OMap = (Key OMap,Value OMap)
hunk ./src/E/SSimplify.hs 120
-collectOccurance e = f e  where
+collectOccurance e = f e where
hunk ./src/E/SSimplify.hs 132
-            Just occ -> tell (mdelete n tfvs,singleton n) >> return (EPi (annb' tvr { tvrType = a }) b)
+            Just occ -> tell (delete n tfvs,singleton n) >> return (EPi (annb' tvr { tvrType = a }) b)
hunk ./src/E/SSimplify.hs 153
-            True ->  tell $ (foldr mdelete avs (map tvrIdent as),fromList $ map tvrIdent as)
-            False -> tell $ (inLam $ foldr mdelete avs (map tvrIdent as),fromList $ map tvrIdent as)
+            True ->  tell $ (foldr delete avs (map tvrIdent as),fromList $ map tvrIdent as)
+            False -> tell $ (inLam $ foldr delete avs (map tvrIdent as),fromList $ map tvrIdent as)
hunk ./src/E/SSimplify.hs 177
-        tell $ (mdelete (tvrIdent b) fidm,singleton (tvrIdent b))
+        tell $ (delete (tvrIdent b) fidm,singleton (tvrIdent b))
hunk ./src/E/SSimplify.hs 188
-        let fvs' = foldr mdelete fvs (map tvrIdent $ litBinds l)
+        let fvs' = foldr delete fvs (map tvrIdent $ litBinds l)
hunk ./src/E/SSimplify.hs 234
-    let (reachable',graph) = newGraphReachable ds' (\ ((comb,_),_) -> combIdent comb) (\ ((_,rv),fv) -> mkeys (fv `mappend` rv))
-        rds = reachable' (mkeys fve ++ [ combIdent t | t <- ds,  (combIdent t `member` exp)])
+    let (reachable',graph) = newGraphReachable ds' (\ ((comb,_),_) -> combIdent comb) (\ ((_,rv),fv) -> keys (fv `mappend` rv))
+        rds = reachable' (keys fve ++ [ combIdent t | t <- ds,  (combIdent t `member` exp)])
hunk ./src/E/SSimplify.hs 238
-        graph' = newGraph rds (\ ((comb,_),_) -> combIdent comb) (\ (_,fv) -> mkeys fv)
+        graph' = newGraph rds (\ ((comb,_),_) -> combIdent comb) (\ (_,fv) -> keys fv)
hunk ./src/E/SSimplify.hs 271
-andOM x y = munionWith andOcc x y
+andOM x y = unionWith andOcc x y
hunk ./src/E/SSimplify.hs 276
-orMaps ms = OMap $ fmap orMany $ foldl (munionWith (++)) mempty (map (fmap (:[])) (map unOMap ms)) where
+orMaps ms = OMap $ fmap orMany $ foldl (unionWith (++)) mempty (map (fmap (:[])) (map unOMap ms)) where
hunk ./src/E/SSimplify.hs 427
-    check n = n `mmember` s || n `mmember` nn
+    check n = n `member` s || n `member` nn
hunk ./src/E/SSimplify.hs 439
-dosub e = ask >>= \inb ->  coerceOpt return (doSubst' False False (envCachedSubst inb) (`mmember` envCachedSubst inb) e)
+dosub e = ask >>= \inb ->  coerceOpt return (doSubst' False False (envCachedSubst inb) (`member` envCachedSubst inb) e)
hunk ./src/E/SSimplify.hs 799
-            Nothing | fopts FO.Rules -> applyRules lup (mfindWithDefault mempty (tvrIdent v) $ envRules inb) xs
+            Nothing | fopts FO.Rules -> applyRules lup (findWithDefault mempty (tvrIdent v) $ envRules inb) xs
hunk ./src/E/Subst.hs 94
-substMap im e = doSubst' False False im (\n -> n `member` (unions $ (freeVars e :: IdSet):map freeVars (melems im))) e
+substMap im e = doSubst' False False im (\n -> n `member` (unions $ (freeVars e :: IdSet):map freeVars (values im))) e
hunk ./src/E/Subst.hs 98
-substMap' im = doSubst' False False im (`mmember` im)
+substMap' im = doSubst' False False im (`member` im)
hunk ./src/E/Subst.hs 102
-substMap'' im = doSubst' False False (mapMaybeIdMap id im) (`mmember` im)
+substMap'' im = doSubst' False False (mapMaybeIdMap id im) (`member` im)
hunk ./src/E/Subst.hs 107
-    = doSubst' substInVars allShadow (mapMaybeIdMap id bm) (`mmember` bm) e
+    = doSubst' substInVars allShadow (mapMaybeIdMap id bm) (`member` bm) e
hunk ./src/E/Subst.hs 151
-        e' <- local (\(s,m) -> (Set.insert n s, mdelete n m)) $ f e
+        e' <- local (\(s,m) -> (Set.insert n s, delete n m)) $ f e
hunk ./src/E/Subst.hs 173
-        return (nvr,\(s,m) -> (Set.insert i' . Set.insert i $ s, minsert i (EVar nvr) . mdelete i' $ m))
+        return (nvr,\(s,m) -> (Set.insert i' . Set.insert i $ s, minsert i (EVar nvr) . delete i' $ m))
hunk ./src/E/Subst.hs 183
-    where scheck n = n `mmember` ss || n `member` s || checkTaken n
+    where scheck n = n `member` ss || n `member` s || checkTaken n
hunk ./src/E/Subst.hs 206
-    fvmap m = unions (map freeVars (melems m))
+    fvmap m = unions (map freeVars (values m))
hunk ./src/E/Type.hs 119
-    deriving(Eq,Ord)
-        {-!derive: is, Functor, Foldable, Traversable !-}
+    deriving(Eq,Ord,Functor,Foldable,Traversable)
+        {-!derive: is !-}
hunk ./src/E/TypeAnalysis.hs 35
-import Util.SetLike
+import Util.SetLike hiding(Value)
hunk ./src/Grin/FromE.hs 238
-    initTyEnv = mappend primTyEnv $ TyEnv $ Map.fromList $ concat [ makePartials (a,b,c) | (_,(a,b,c)) <-  massocs scMap] ++ concat [con x| x <- [cabsurd] ++ Map.elems (constructorMap dataTable), conType x /= eHash]
+    initTyEnv = mappend primTyEnv $ TyEnv $ Map.fromList $ concat [ makePartials (a,b,c) | (_,(a,b,c)) <-  toList scMap] ++ concat [con x| x <- [cabsurd] ++ Map.elems (constructorMap dataTable), conType x /= eHash]
hunk ./src/Ho/Build.hs 851
-        putStrLn $ "Modules contained:" <+> tshow (mkeys $ hoExports hoE)
+        putStrLn $ "Modules contained:" <+> tshow (keys $ hoExports hoE)
hunk ./src/Ho/Collected.hs 34
-choEs cho = [ (combHead c,combBody c) | c <- melems $  choCombinators cho]
+choEs cho = [ (combHead c,combBody c) | c <- values $  choCombinators cho]
hunk ./src/Ho/Collected.hs 59
-        mmap = mfilterWithKey (\k _ -> (k `notElem` (map (tvrIdent . fst) ds))) (choVarMap cho)
+        mmap = sfilter (\(k,_) -> (k `notElem` (map (tvrIdent . fst) ds))) (choVarMap cho)
hunk ./src/Ho/Collected.hs 67
-mergeChoVarMaps x y = munionWith f x y where
+mergeChoVarMaps x y = unionWith f x y where
hunk ./src/Ho/Collected.hs 79
-mergeChoCombinators x y = munionWith f x y where
+mergeChoCombinators x y = unionWith f x y where
hunk ./src/Info/Binary.hs 57
-    put (Properties (EnumBitSet props)) = put (fromIntegral $ BS.toWord props :: Word32)
-    get = (get :: Get Word32) >>= return . Properties . EnumBitSet . BS.fromWord . fromIntegral
+    put (Properties (EBS props)) = put (fromIntegral $ BS.toWord props :: Word32)
+    get = (get :: Get Word32) >>= return . Properties . EBS . BS.fromWord . fromIntegral
hunk ./src/Main.hs 85
-        combinators = melems $ choCombinators cho
+        combinators = values $ choCombinators cho
hunk ./src/Name/Id.hs 57
-import Util.GMap()
+import Util.GMap
hunk ./src/Name/Id.hs 84
+
+
hunk ./src/Name/Id.hs 100
+instance Intjection Id where
+    toIntjection i = (Id i)
+    fromIntjection (Id i) = i
+
+type IdSet = IntjectionSet Id
+type instance GSet Id = IdSet
hunk ./src/Name/Id.hs 107
+{-
hunk ./src/Name/Id.hs 123
+-}
hunk ./src/Name/Id.hs 126
-idSetToList (IdSet is) = [ Id x | x <- IS.toList is ]
+idSetToList = S.toList
hunk ./src/Name/Id.hs 129
-idMapToList (IdMap is) = [ (Id x,y) | (x,y) <- IM.toList is ]
+idMapToList = S.toList
hunk ./src/Name/Id.hs 135
-mapMaybeIdMap fn (IdMap m) = IdMap (IM.mapMaybe fn m)
+mapMaybeIdMap fn (IntjectionMap m) = IntjectionMap (IM.mapMaybe fn m)
hunk ./src/Name/Id.hs 138
--- IdMap
+type IdMap = IntjectionMap Id
+type instance GMap Id = IdMap
hunk ./src/Name/Id.hs 141
+{-
hunk ./src/Name/Id.hs 164
+-}
+
+instance GMapSet Id where
+    toSet (IntjectionMap im)  = IntjectionSet $ IM.keysSet im
+    toMap f (IntjectionSet is) = IntjectionMap $ IM.fromDistinctAscList [ (x,f (Id x)) |  x <- IS.toAscList is]
+    
hunk ./src/Name/Id.hs 175
-idSetToIdMap f (IdSet is) = IdMap $ IM.fromDistinctAscList [ (x,f (Id x)) |  x <- IS.toAscList is]
+--idSetToIdMap f (IdSet is) = IdMap $ IM.fromDistinctAscList [ (x,f (Id x)) |  x <- IS.toAscList is]
+idSetToIdMap = toMap
hunk ./src/Name/Id.hs 179
-idMapToIdSet (IdMap im) = IdSet $ (IM.keysSet im)
-
+idMapToIdSet (IntjectionMap im)  = IntjectionSet $ IM.keysSet im
+--idMapToIdSet (IdMap im) = IdSet $ (IM.keysSet im)
hunk ./src/Name/Id.hs 230
-idSetFromDistinctAscList ids = IdSet (IS.fromDistinctAscList [ x | Id x <- ids] )
+idSetFromDistinctAscList ids = IntjectionSet (IS.fromDistinctAscList [ x | Id x <- ids] )
hunk ./src/Name/Id.hs 233
-idSetFromList ids = IdSet (IS.fromList [ x | Id x <- ids])
+idSetFromList ids = fromList ids
hunk ./src/Name/Id.hs 236
-idMapFromList ids = IdMap (IM.fromList [ (x,y) | (Id x,y) <- ids])
+idMapFromList ids = fromList  ids
hunk ./src/Name/Id.hs 239
-idMapFromDistinctAscList ids = IdMap (IM.fromDistinctAscList [ (x,y) | (Id x,y) <- ids ] )
-
-
+idMapFromDistinctAscList ids = IntjectionMap (IM.fromDistinctAscList [ (x,y) | (Id x,y) <- ids ] )
hunk ./src/Name/Id.hs 277
-newIds (IdSet ids) = [ i | i <- candidateIds (size ids' `xor` IS.findMin ids' `xor` IS.findMax ids') , i `notMember` IdSet ids ] where
+newIds (IntjectionSet ids) = [ Id i | Id i <- candidateIds (size ids' `xor` IS.findMin ids' `xor` IS.findMax ids') , i `notMember` ids ] where
hunk ./src/Util/BitSet.hs 99
---    type Elem (EnumBitSet a) = a
hunk ./src/Util/GMap.hs 4
-import qualified Data.Map as M
+import Util.SetLike
hunk ./src/Util/GMap.hs 6
-import qualified Data.Set as S
hunk ./src/Util/GMap.hs 7
+import Util.HasSize
+import Data.Foldable hiding(toList)
+import Data.Traversable
hunk ./src/Util/GMap.hs 11
-class Monoid s => Collection s where
-    type Elem s :: *
-    fromList :: [Elem s] -> s
-    toList :: s -> [Elem s]
-    singleton :: Elem s -> s
-    singleton e = fromList [e]
hunk ./src/Util/GMap.hs 12
-instance Collection [e] where
-    type Elem [e] = e
-    fromList = id
-    toList = id
+type family GMap k :: * -> *
+type family GSet k :: *
hunk ./src/Util/GMap.hs 15
-class Collection s => SetLike s where
-    type Key s :: *
-    keys :: s -> [Key s]
-    member :: Key s -> s -> Bool
-    delete :: Key s -> s -> s
-    union :: s -> s -> s
-    unions :: [s] -> s
-    difference :: s -> s -> s
-    filter :: (Elem s -> Bool) -> s -> s
-    insert :: Elem s -> s -> s
+type instance GMap Int = IM.IntMap
+type instance GSet Int = IS.IntSet
hunk ./src/Util/GMap.hs 18
-    unions = mconcat
-    union = mappend
+type instance GSet Char = EnumSet Char
+type instance GMap Char = EnumMap Char
hunk ./src/Util/GMap.hs 21
-class SetLike m => MapLike m where
-    type Value m :: *
-    lookup :: Key m -> m -> Maybe (Value m)
-    values :: m -> [Value m]
+newtype EnumSet a = EnumSet IS.IntSet
+    deriving(Monoid,IsEmpty,HasSize,Unionize,Eq,Ord)
hunk ./src/Util/GMap.hs 24
-instance Collection IS.IntSet where
-    type Elem IS.IntSet = Int
-    fromList = IS.fromList
-    toList = IS.toList
-    singleton = IS.singleton
+type instance Elem (EnumSet a) = a
+type instance Key (EnumSet a) = a
hunk ./src/Util/GMap.hs 27
-instance SetLike IS.IntSet where
-    type Key IS.IntSet = Int
-    keys = IS.toList
-    member = IS.member
-    filter = IS.filter
-    delete = IS.delete
-    union = IS.union
-    difference = IS.difference
-    insert = IS.insert
+instance Enum a => Collection (EnumSet a) where 
+    singleton i = EnumSet $ singleton (fromEnum i)
+    fromList ts = EnumSet $ fromList (map fromEnum ts)
+    toList (EnumSet w) = map toEnum $ toList w
hunk ./src/Util/GMap.hs 32
-instance Ord k => Collection (S.Set k) where
-    type Elem (S.Set k) = k
-    fromList = S.fromList
-    toList = S.toList
-    singleton = S.singleton
+instance Enum a => SetLike (EnumSet a) where
+    keys = toList
+    delete (fromEnum -> i) (EnumSet v) = EnumSet $ delete i v
+    member (fromEnum -> i) (EnumSet v) = member i v
+    insert (fromEnum -> i) (EnumSet v) = EnumSet $ insert i v
+    sfilter f (EnumSet v) = EnumSet $ sfilter (f . toEnum) v
+    spartition f (EnumSet v) = case spartition (f . toEnum) v of
+        (x,y) -> (EnumSet x,EnumSet y)
hunk ./src/Util/GMap.hs 41
-instance Ord k => SetLike (S.Set k) where
-    type Key (S.Set k) = k
-    keys = S.toList
-    member = S.member
-    filter = S.filter
-    delete = S.delete
-    union = S.union
-    difference = S.difference
-    insert = S.insert
+newtype EnumMap k v = EnumMap (IM.IntMap v)
+    deriving(Monoid,IsEmpty,Functor,Foldable,Traversable,HasSize,Unionize,Eq,Ord)
hunk ./src/Util/GMap.hs 44
-instance Collection (IM.IntMap v) where
-    type Elem (IM.IntMap v) = (Int,v)
-    fromList = IM.fromList
-    toList = IM.toList
-    singleton (k,v) = IM.singleton k v
+type instance Elem (EnumMap k v) = (k,v)
+type instance Key (EnumMap k v) = k
+type instance Value (EnumMap k v) = v
hunk ./src/Util/GMap.hs 48
-instance SetLike (IM.IntMap v) where
-    type Key (IM.IntMap v) = Int
-    keys = IM.keys
-    member = IM.member
-    filter f = IM.filterWithKey (\ k v -> f (k,v))
-    delete = IM.delete
-    union = IM.union
-    difference = IM.difference
-    insert (k,v) = IM.insert k v
+instance Enum k => Collection (EnumMap k v) where 
+    singleton (k,v) = EnumMap $ singleton (fromEnum k,v)
+    fromList ts = EnumMap $ fromList [ (fromEnum k,v) | (k,v) <- ts ]
+    toList (EnumMap kv) =  [ (toEnum k,v)  | (k,v) <-  toList kv]
hunk ./src/Util/GMap.hs 53
-instance MapLike (IM.IntMap v) where
-    type Value (IM.IntMap v) = v
-    lookup = IM.lookup
-    values = IM.elems
+instance Enum k => SetLike (EnumMap k v) where
+    keys (EnumMap v) = map toEnum $ keys v
+    delete (fromEnum -> i) (EnumMap v) = EnumMap $ delete i v
+    member (fromEnum -> i) (EnumMap v) = member i v
+    insert (fromEnum -> k,v) (EnumMap m) = EnumMap $ insert (k,v) m
+    sfilter f (EnumMap v) = EnumMap $ sfilter (\ (k,v) -> f (toEnum k,v)) v
+    spartition f (EnumMap v) = case spartition (\ (k,v) -> f (toEnum k,v)) v of
+        (x,y) -> (EnumMap x,EnumMap y)
hunk ./src/Util/GMap.hs 62
-instance Ord k => Collection (M.Map k v) where
-    type Elem (M.Map k v) = (k,v)
-    fromList = M.fromList
-    toList = M.toList
-    singleton (k,v) = M.singleton k v
+instance Enum k => MapLike (EnumMap k v) where
+    mlookup (fromEnum -> i) (EnumMap v) = mlookup i v
+    values (EnumMap v) = values v
+    unionWith f (EnumMap x) (EnumMap y) = EnumMap $ unionWith f x y
+    
hunk ./src/Util/GMap.hs 68
-instance Ord k => SetLike (M.Map k v) where
-    type Key (M.Map k v) = k
-    keys = M.keys
-    member = M.member
-    filter f = M.filterWithKey (\ k v -> f (k,v))
-    delete = M.delete
-    union = M.union
-    difference = M.difference
-    insert (k,v) = M.insert k v
+class GMapSet k where
+    toSet :: GMap k v -> GSet k
+    toMap :: (k -> v) -> GSet k -> GMap k v
hunk ./src/Util/GMap.hs 72
-instance Ord k => MapLike (M.Map k v) where
-    type Value (M.Map k v) = v
-    lookup = M.lookup
-    values = M.elems
+-- must be an injection into the integers
+class Intjection a where
+    fromIntjection :: a -> Int
+    toIntjection :: Int -> a
hunk ./src/Util/GMap.hs 77
-minsert :: (MapLike m, Elem m ~ (k,v)) => k -> v -> m -> m
-minsert k v = insert (k,v)
+newtype IntjectionSet a = IntjectionSet IS.IntSet
+    deriving(Monoid,IsEmpty,HasSize,Unionize,Eq,Ord)
hunk ./src/Util/GMap.hs 80
-{-
-instance SetLike (GMap k v) where
-    type Elem (GMap k v) = (k,v)
-    type Key (GMap k v) = k
+type instance Elem (IntjectionSet a) = a
+type instance Key (IntjectionSet a) = a
+
+instance Intjection a => Collection (IntjectionSet a) where 
+    singleton i = IntjectionSet $ singleton (fromIntjection i)
+    fromList ts = IntjectionSet $ fromList (map fromIntjection ts)
+    toList (IntjectionSet w) = map toIntjection $ toList w
+
+instance Intjection a => SetLike (IntjectionSet a) where
+    keys = toList
+    delete (fromIntjection -> i) (IntjectionSet v) = IntjectionSet $ delete i v
+    member (fromIntjection -> i) (IntjectionSet v) = member i v
+    insert (fromIntjection -> i) (IntjectionSet v) = IntjectionSet $ insert i v
+    sfilter f (IntjectionSet v) = IntjectionSet $ sfilter (f . toIntjection) v
+    spartition f (IntjectionSet v) = case spartition (f . toIntjection) v of
+        (x,y) -> (IntjectionSet x,IntjectionSet y)
+
+newtype IntjectionMap k v = IntjectionMap (IM.IntMap v)
+    deriving(Monoid,IsEmpty,Functor,Foldable,Traversable,HasSize,Unionize,Eq,Ord)
+
+type instance Elem (IntjectionMap k v) = (k,v)
+type instance Key (IntjectionMap k v) = k
+type instance Value (IntjectionMap k v) = v
+
+instance Intjection k => Collection (IntjectionMap k v) where 
+    singleton (k,v) = IntjectionMap $ singleton (fromIntjection k,v)
+    fromList ts = IntjectionMap $ fromList [ (fromIntjection k,v) | (k,v) <- ts ]
+    toList (IntjectionMap kv) =  [ (toIntjection k,v)  | (k,v) <-  toList kv]
hunk ./src/Util/GMap.hs 109
-instance SetLike (GSet k) where
-    type Elem (GSet k) = k
-    type Key (GSet k) = k
+instance Intjection k => SetLike (IntjectionMap k v) where
+    keys (IntjectionMap v) = map toIntjection $ keys v
+    delete (fromIntjection -> i) (IntjectionMap v) = IntjectionMap $ delete i v
+    member (fromIntjection -> i) (IntjectionMap v) = member i v
+    insert (fromIntjection -> k,v) (IntjectionMap m) = IntjectionMap $ insert (k,v) m
+    sfilter f (IntjectionMap v) = IntjectionMap $ sfilter (\ (k,v) -> f (toIntjection k,v)) v
+    spartition f (IntjectionMap v) = case spartition (\ (k,v) -> f (toIntjection k,v)) v of
+        (x,y) -> (IntjectionMap x,IntjectionMap y)
hunk ./src/Util/GMap.hs 118
+instance Intjection k => MapLike (IntjectionMap k v) where
+    mlookup (fromIntjection -> i) (IntjectionMap v) = mlookup i v
+    values (IntjectionMap v) = values v
+    unionWith f (IntjectionMap x) (IntjectionMap y) = IntjectionMap $ unionWith f x y
hunk ./src/Util/GMap.hs 123
-class GMapKey k where
-    data GMap k :: * -> *
-    data GSet k :: *
+--type instance Elem  (GMap k v) = (k,v)
+--type instance Key   (GMap k v) = k
+--type instance Value (GMap k v) = k
+
+--instance Collection (GMap k v) 
+--instance SetLike (GMap k v) where
+
+--instance SetLike (GSet k) where
+--    type Elem (GSet k) = k
+--    type Key (GSet k) = k
+
+
+--class GMapKey k where
+--    data GMap k :: * -> *
+--    data GSet k :: *
hunk ./src/Util/GMap.hs 151
-instance GMapKey Int where
+{-
+//instance GMapKey Int where
hunk ./src/Util/SetLike.hs 3
+import Data.List(foldl')
hunk ./src/Util/SetLike.hs 9
+import Util.HasSize
+
+infixl 9 \\ --
+
+(\\) :: Unionize s => s -> s -> s
+m1 \\ m2 = difference m1 m2
hunk ./src/Util/SetLike.hs 18
-    unions :: [s] -> s
hunk ./src/Util/SetLike.hs 20
-    unions = mconcat
+    unions :: [s] -> s
+    sempty :: s
+
+    sempty = mempty
hunk ./src/Util/SetLike.hs 25
+    unions = foldl' union mempty
hunk ./src/Util/SetLike.hs 33
+    fromDistinctAscList :: [Elem s] -> s
hunk ./src/Util/SetLike.hs 38
+    fromDistinctAscList = fromList
+
hunk ./src/Util/SetLike.hs 53
+    spartition :: (Elem s -> Bool) -> s -> (s,s)
hunk ./src/Util/SetLike.hs 55
+notMember :: SetLike s => Key s -> s -> Bool
+notMember k s = not $ member k s
hunk ./src/Util/SetLike.hs 61
+    unionWith :: (Value m -> Value m -> Value m) -> m -> m -> m
hunk ./src/Util/SetLike.hs 82
+    spartition = IS.partition
hunk ./src/Util/SetLike.hs 102
+    spartition = S.partition
hunk ./src/Util/SetLike.hs 122
+    spartition f = IM.partitionWithKey (\ k v -> f (k,v))
hunk ./src/Util/SetLike.hs 128
+    unionWith = IM.unionWith
hunk ./src/Util/SetLike.hs 148
+    spartition f = M.partitionWithKey (\ k v -> f (k,v))
hunk ./src/Util/SetLike.hs 154
+    unionWith = M.unionWith
hunk ./src/Util/SetLike.hs 159
+msingleton :: (MapLike m, Elem m ~ (k,v)) => k -> v -> m
+msingleton k v = singleton (k,v)
+
+intersects x y = not $ isEmpty (x `intersection` y)
+
+findWithDefault :: MapLike m => Value m -> Key m -> m -> Value m
+findWithDefault d k m = case mlookup k m of
+    Nothing -> d
+    Just x -> x