[move a lot of stuff to Util clean up code, remove unneeded module
John Meacham <john@repetae.net>**20050923035945] hunk ./DDataUtil.hs 1
-module DDataUtil(Elems(..),Member(..)) where
-
-import qualified Data.IntSet as IS
-import qualified Data.IntMap as IM
-import qualified Data.Set as Set
-import qualified Data.Map as Map
-
-
-
-class Elems xs k v  | xs -> k v where
-    elems :: xs -> [v]
-    keys :: xs -> [k]
-    assocs :: xs -> [(k,v)]
-
-    assocs x = zip (keys x) (elems x)
-    elems x = [ y | (_,y) <- assocs x]
-    keys x =  [ x | (x,_) <- assocs x]
-
-instance Elems (Set.Set x) x x where
-    elems = Set.elems
-    keys = Set.elems
-
-instance Elems IS.IntSet Int Int where
-    elems = IS.elems
-    keys = IS.elems
-
-instance Elems (Map.Map a b) a b where
-    assocs = Map.assocs
-    keys = Map.keys
-    elems = Map.elems
-
-instance Elems (IM.IntMap x) Int x where
-    assocs = IM.assocs
-    keys = IM.keys
-    elems = IM.elems
-
-instance Elems x y z => Elems (Maybe x) y z where
-    keys Nothing = []
-    keys (Just x) = keys x
-    elems (Just x) = elems x
-    elems Nothing = []
-    assocs (Just x) = assocs x
-    assocs Nothing = []
-
-class Member m k | m -> k where
-    member :: k -> m -> Bool
-    notMember :: k -> m -> Bool
-
-    notMember k m = not $ member k m
-    member k m = not $ notMember k m
-
-instance Ord a => Member (Set.Set a) a where
-    member = Set.member
-instance Ord k => Member (Map.Map k v) k where
-    member = Map.member
-instance Member (IM.IntMap v) Int where
-    member = IM.member
-instance Member IS.IntSet Int where
-    member = IS.member
-
-
-
-{-
-instance Monad Set.Set where
-    a >>= b = Set.unions (map b (Set.toList a))
-    return x = Set.single x
-    fail _ = Set.empty
--}
-{-
-instance Monoid IS.IntSet where
-    mempty = IS.empty
-    mappend = IS.union
-    mconcat = IS.unions
-
-instance Monoid (IM.IntMap a) where
-    mempty = IM.empty
-    mappend = IM.union
-    mconcat = IM.unions
-
-instance Ord a => Monoid (Set.Set a) where
-    mempty = Set.empty
-    mappend = Set.union
-    mconcat = Set.unions
-
-instance Ord k => Monoid (Map.Map k v ) where
-    mempty = Map.empty
-    mappend = Map.union
-    mconcat = Map.unions
-
-
-
-instance Functor IM.IntMap where
-    fmap = IM.map
-
---instance Ord k => Functor (Map.Map k) where
---    fmap = Map.map
-
-
-instance HasSize (Map.Map a b) where
-    size = Map.size
-instance HasSize (Set.Set a) where
-    size = Set.size
-instance HasSize IS.IntSet where
-    size = IS.size
--}
-
rmfile ./DDataUtil.hs
hunk ./C/FromGrin.hs 11
-import DDataUtil()
hunk ./DataConstructors.hs 16
-import Binary
hunk ./DataConstructors.hs 19
+import List(sortBy)
+import qualified Data.IntMap as IM
+
+import Binary
hunk ./DataConstructors.hs 30
-import HasSize
hunk ./DataConstructors.hs 31
-import List(sortBy)
hunk ./DataConstructors.hs 34
-import qualified Data.IntMap as IM
hunk ./DataConstructors.hs 37
-import SameShape
+import Util.HasSize
+import Util.SameShape
hunk ./E/E.hs 11
-import DDataUtil()
hunk ./E/FromHs.hs 14
-import DDataUtil()
hunk ./E/Inline.hs 11
-import GraphUtil
-import HasSize
+import Util.Graph
+import Util.HasSize
hunk ./E/LambdaLift.hs 19
-import GraphUtil as G
hunk ./E/LambdaLift.hs 22
+import Util.Graph as G
hunk ./E/LetFloat.hs 12
-
-import Atom
+import Control.Monad.Identity
hunk ./E/LetFloat.hs 15
-import DDataUtil()
+import List
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+
+import Atom
hunk ./E/LetFloat.hs 22
+import E.Rules
+import E.Subst(app)
hunk ./E/LetFloat.hs 26
-import E.Rules
hunk ./E/LetFloat.hs 28
-import GraphUtil
-import List
-import qualified GraphUtil as G
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import SameShape
+import qualified Util.Graph as G
hunk ./E/LetFloat.hs 30
-import E.Subst(app)
-import Control.Monad.Identity
+import Util.SameShape
hunk ./E/LetFloat.hs 140
-    letRec xs e = f (G.scc $ G.newGraph (concatMap fromScc xs) (tvrNum . fst . fst) (Set.toList . snd)) where
+    letRec xs e = f (G.scc $ G.newGraph (concatMap G.fromScc xs) (tvrNum . fst . fst) (Set.toList . snd)) where
hunk ./E/LetFloat.hs 152
-    g = G.reachable (G.newGraph (concatMap fromScc xs) (tvrNum . fst . fst) (Set.toList . snd)) (fvs `mappend` (map (tvrNum . fst . fst) $ concatMap fromScc unsafe_ones))
+    g = G.reachable (G.newGraph (concatMap G.fromScc xs) (tvrNum . fst . fst) (Set.toList . snd)) (fvs `mappend` (map (tvrNum . fst . fst) $ concatMap G.fromScc unsafe_ones))
hunk ./E/LetFloat.hs 157
-    ind x = any ( (`elem` uso) . tvrNum . fst . fst ) (fromScc x)
+    ind x = any ( (`elem` uso) . tvrNum . fst . fst ) (G.fromScc x)
hunk ./E/Rules.hs 30
-import HasSize
+import Util.HasSize
hunk ./E/SSimplify.hs 3
-import Atom
-import CanType
hunk ./E/SSimplify.hs 5
-import DataConstructors
hunk ./E/SSimplify.hs 8
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+
+import Atom
+import CanType
+import DataConstructors
hunk ./E/SSimplify.hs 21
-import GraphUtil
hunk ./E/SSimplify.hs 24
-import qualified Data.Map as Map
-import qualified Data.Set as Set
hunk ./E/SSimplify.hs 29
+import Util.Graph
hunk ./E/Strictness.hs 7
-import DDataUtil()
hunk ./FrontEnd/Class.hs 59
-import DDataUtil
hunk ./FrontEnd/Class.hs 62
-import HasSize
+import Util.HasSize
hunk ./FrontEnd/Infix.hs 23
-import DDataUtil()
-import HasSize
+import Util.HasSize
hunk ./FrontEnd/MultiModuleBasics.hs 24
-import DDataUtil()
hunk ./FrontEnd/TypeSynonyms.hs 8
-import HsSyn
-import HsErrors
-import Control.Monad.Writer
hunk ./FrontEnd/TypeSynonyms.hs 9
+import Control.Monad.Writer
+import Data.Monoid
hunk ./FrontEnd/TypeSynonyms.hs 12
-import GenUtil
-import Doc.DocLike
-import Warning
hunk ./FrontEnd/TypeSynonyms.hs 13
-import Data.Monoid
-import Name
+
hunk ./FrontEnd/TypeSynonyms.hs 15
-import HasSize
+import Doc.DocLike
+import GenUtil
+import HsErrors
+import HsSyn
+import Name
+import Util.HasSize
+import Warning
hunk ./GraphUtil.hs 1
--- | Data.Graph is sorely lacking in several ways, This just tries to fill in
--- some holes and provide a more convinient interface
-
-module GraphUtil where
-
-import qualified Data.Graph
-import Data.Graph hiding(Graph)
-import GenUtil
-import Array
-import List(sort,sortBy,group,delete)
-
-
-data Graph n k = Graph Data.Graph.Graph (Vertex -> n) (k -> Maybe Vertex) (n -> k)
-
-instance Show n => Show (Graph n k) where
-    showsPrec n g = showsPrec n (GraphUtil.scc g)
-
-newGraph :: Ord k => [n] -> (n -> k) -> (n -> [k]) -> Graph n k
-newGraph ns fn fd = Graph ans lv' kv fn where
-    (ans,lv,kv) = graphFromEdges [ (n,fn n,snub $ fd n) | n <- ns ]
-    lv' x | (n,_,_) <- lv x = n
-
-fromScc (Left n) = [n]
-fromScc (Right n) = n
-
--- | determine a set of loopbreakers subject to a fitness function
--- loopbreakers have a minimum of their  incoming edges ignored.
-findLoopBreakers ::
-    (n -> Int)    -- ^ fitness function, greater numbers mean more likely to be a loopbreaker
-    -> Graph n k  -- ^ the graph
-    ->  ([n],[n]) -- ^ (loop breakers,dependency ordered nodes after loopbreaking)
-findLoopBreakers func (Graph g ln kv fn) = ans where
-    scc = Data.Graph.scc g
-    ans = f g scc [] [] where
-        f g (Node v []:sccs) fs lb
-            | v `elem` g ! v = let ng = (fmap (List.delete v) g) in  f ng (Data.Graph.scc ng) [] (v:lb)
-            | otherwise = f g sccs (v:fs) lb
-
-        f g (n:_) fs lb = f ng (Data.Graph.scc ng) [] (mv:lb) where
-            ((mv,_):_) = sortBy (\ a b -> compare (snd b) (snd a)) [ (v,func (ln v)) | v <- ns]
-            ns = dec n []
-            ng = fmap (List.delete mv) g
-
-        f _ [] xs lb = (map (ln . head) (group $ sort lb),reverse $ map ln xs)
-    dec (Node v ts) vs = v:foldr dec vs ts
-
-
-sccGroups :: Graph n k -> [[n]]
-sccGroups g = map fromScc (GraphUtil.scc g)
-
-scc :: Graph n k -> [Either n [n]]
-scc (Graph g ln kv fn) = map decode forest where
-    forest = Data.Graph.scc g
-    decode (Node v [])
-        | v `elem` g ! v = Right [ln v]
-        | otherwise = Left (ln v)
-    decode other = Right (dec other [])
-    dec (Node v ts) vs = ln v:foldr dec vs ts
-
-
-reachable :: Graph n k -> [k] -> [n]
-reachable (Graph g ln kv _) ns = map ln $ snub $  concatMap (Data.Graph.reachable g) gs where
-    gs = [ v | Just v <- map kv ns]
-
-topSort :: Graph n k -> [n]
-topSort (Graph g ln _ _) = map ln $ Data.Graph.topSort g
-
-cyclicNodes :: Graph n k -> [n]
-cyclicNodes g = concat [ xs | Right xs <- GraphUtil.scc g]
-
rmfile ./GraphUtil.hs
hunk ./Grin/Fizz.hs 11
-import DDataUtil()
hunk ./Grin/FromE.hs 17
-import DDataUtil()
hunk ./Grin/FromE.hs 28
-import GraphUtil as G
hunk ./Grin/FromE.hs 36
+import Util.Graph as G
hunk ./Grin/Grin.hs 51
-import DDataUtil()
hunk ./Grin/HashConst.hs 3
-import Grin.Grin
-import Atom
hunk ./Grin/HashConst.hs 5
-import GraphUtil
+
+import Atom
+import Grin.Grin
+import Util.Graph
hunk ./Grin/PointsToAnalysis.hs 9
-import DDataUtil()
hunk ./Grin/Simplify.hs 12
-import DDataUtil()
hunk ./Grin/Whiz.hs 10
-import DDataUtil()
hunk ./HasSize.hs 1
-module HasSize where
-
--- this point of this module is not only to share the 'size' syntax, but to
--- provide optimally lazy versions of size comparasin functions when dealing
--- with lazy structures. This is especially useful when having to compare the
--- size of possibly long lists.
-
--- it is up to each instance to decide what 'size' means
-
-import qualified Data.Map(Map,size)
-import qualified Data.Set(Set,size)
-import qualified Data.IntMap(IntMap,size)
-import qualified Data.IntSet(IntSet,size)
-
-
-class HasSize a where
-    size :: a -> Int
-    sizeEQ :: Int -> a -> Bool
-    sizeGT :: Int -> a -> Bool
-    sizeLT :: Int -> a -> Bool
-    sizeGTE :: Int -> a -> Bool
-    sizeLTE :: Int -> a -> Bool
-    sizeEQ s x = size x == s
-    sizeGT s x = size x > s
-    sizeLT s x = size x < s
-    sizeGTE s x = not $ sizeLT s x
-    sizeLTE s x = not $ sizeGT s x
-
-genSize :: (Integral b,HasSize a) => a -> b
-genSize = fromIntegral . HasSize.size
-
-instance HasSize [x] where
-    size = length
-    sizeEQ n _ | n < 0 = False
-    sizeEQ n xs = f n xs where
-        f 0 [] = True
-        f _ [] = False
-        f 0 _ = False
-        f n (_:xs) = sizeEQ (n - 1) xs
-    sizeGT n _ | n < 0 = True
-    sizeGT n xs = f n xs where
-        f 0 (_:_) = True
-        f n [] = False
-        f n (_:xs) = f (n - 1) xs
-    sizeLT n _ | n <= 0 = False
-    sizeLT n xs = f n xs where
-        f 0 _ = False
-        f _ [] = True
-        f n (_:xs) = f (n - 1) xs
-
-
-
-instance HasSize (Data.Map.Map a b) where
-    size = Data.Map.size
-
-
-instance HasSize (Data.Set.Set a) where
-    size = Data.Set.size
-
-instance HasSize (Data.IntMap.IntMap v) where
-    size = Data.IntMap.size
-instance HasSize Data.IntSet.IntSet where
-    size = Data.IntSet.size
-
-instance (HasSize a,HasSize b) => HasSize (Either a b) where
-    size (Left x) = size x
-    size (Right y) = size y
-    sizeEQ s (Left x)  = sizeEQ s x
-    sizeEQ s (Right x)  = sizeEQ s x
-    sizeLT s (Left x)  = sizeLT s x
-    sizeLT s (Right x)  = sizeLT s x
-    sizeGT s (Left x)  = sizeGT s x
-    sizeGT s (Right x)  = sizeGT s x
-
-instance (HasSize a,HasSize b) => HasSize (a,b) where
-    size (x,y) = size x + size y
-
-instance (HasSize a,HasSize b,HasSize c) => HasSize (a,b,c) where
-    size (x,y,z) = size x + size y  + size z
-
rmfile ./HasSize.hs
hunk ./Info/Info.hs 4
-import Data.Monoid
hunk ./Info/Info.hs 5
-import HasSize
+import Data.Monoid
hunk ./Info/Info.hs 8
+
+
hunk ./Info/Info.hs 11
+import Util.HasSize
hunk ./Main.hs 5
+import Control.Exception
+import Control.Monad.Identity
hunk ./Main.hs 10
+import qualified Data.IntMap as IM
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+import qualified System
hunk ./Main.hs 18
-import Control.Exception
-import Control.Monad.Identity
hunk ./Main.hs 23
+import E.Arbitrary()
hunk ./Main.hs 38
-import GraphUtil
hunk ./Main.hs 47
-import qualified Data.IntMap as IM
-import qualified Data.Map as Map
-import qualified Data.Set as Set
hunk ./Main.hs 56
-import qualified System
-
-import E.Arbitrary()
+import Util.Graph
hunk ./SameShape.hs 1
-module SameShape where
-
-import Data.Tree
-
-
-
---class SameShape a b where
---    sameShape :: a -> b -> Bool
-
---instance (SameShape1 f) => SameShape (f a) (f b) where
---    sameShape x y = sameShape1 x y
---instance (SameShape2 f) => SameShape (f a b) (f c d) where
---    sameShape x y = sameShape2 x y
-
-class SameShape1 f where
-    sameShape1 :: f a -> f b -> Bool
-class SameShape2 f where
-    sameShape2 :: f a b -> f c d -> Bool
-
-
-instance SameShape1 [] where
-    sameShape1 [] [] = True
-    sameShape1 (_:xs) (_:ys) = sameShape1 xs ys
-    sameShape1 _ _ = False
-
-instance SameShape1 Tree where
-    sameShape1 (Node _ xs) (Node _ ys) = f xs ys where
-        f [] [] = True
-        f (x:xs) (y:ys) = sameShape1 x y && f xs ys
-        f _ _ = False
-
-instance SameShape1 Maybe where
-    sameShape1 (Just _) (Just _) = True
-    sameShape1 Nothing Nothing = True
-    sameShape1 _ _ = False
-
-instance SameShape2 Either where
-    sameShape2 (Left _) (Left _) = True
-    sameShape2 (Right _) (Right _) = True
-    sameShape2 _ _ = False
-
-instance SameShape1 IO where
-    sameShape1 _ _ = True
-
-
rmfile ./SameShape.hs
hunk ./SelfTest.hs 3
+import Data.Monoid
+import Monad
+import System.IO
hunk ./SelfTest.hs 7
+
+import ArbitraryInstances()
hunk ./SelfTest.hs 10
+import Binary
hunk ./SelfTest.hs 12
-import ArbitraryInstances()
-import PackedString
-import HasSize
-import Name
-import HsSyn
hunk ./SelfTest.hs 13
-import Info.Info as Info
-import Monad
-import Data.Monoid
-import Binary
+import E.E
+import HsSyn
hunk ./SelfTest.hs 16
+import Info.Info as Info
hunk ./SelfTest.hs 18
-import System.IO
-import E.E
+import Name
+import PackedString
+import Util.HasSize