[move FreeVars to Support directory. add ShowTable class
John Meacham <john@repetae.net>**20060129085154] move ./FreeVars.hs ./Support/FreeVars.hs
addfile ./Support/ShowTable.hs
hunk ./C/FromGrin.hs 20
-import FreeVars
+import Support.FreeVars
hunk ./E/Arbitrary.hs 15
-import FreeVars
+import Support.FreeVars
hunk ./E/Diff.hs 9
-import FreeVars
+import Support.FreeVars
hunk ./E/FreeVars.hs 4
-import FreeVars
+import Support.FreeVars
hunk ./E/FromHs.hs 28
-import FreeVars
+import Support.FreeVars
hunk ./E/Inline.hs 12
-import FreeVars
+import Support.FreeVars
hunk ./E/LambdaLift.hs 18
-import FreeVars
+import Support.FreeVars
hunk ./E/LetFloat.hs 25
-import FreeVars
+import Support.FreeVars
hunk ./E/Pretty.hs 13
-import FreeVars
+import Support.FreeVars
hunk ./E/PrimOpt.hs 16
-import FreeVars
+import Support.FreeVars
hunk ./E/Rules.hs 33
-import FreeVars
+import Support.FreeVars
hunk ./E/SSimplify.hs 25
-import FreeVars
+import Support.FreeVars
hunk ./E/Subst.hs 13
-import FreeVars
+import Support.FreeVars
hunk ./E/Traverse.hs 19
-import FreeVars
+import Support.FreeVars
hunk ./E/Values.hs 18
-import FreeVars
+import Support.FreeVars
hunk ./Grin/DeadCode.hs 12
-import FreeVars
+import Support.FreeVars
hunk ./Grin/DeadFunctions.hs 14
-import FreeVars
+import Support.FreeVars
hunk ./Grin/FromE.hs 25
-import FreeVars
+import Support.FreeVars
hunk ./Grin/Grin.hs 66
-import FreeVars
+import Support.FreeVars
hunk ./Grin/Simplify.hs 14
-import FreeVars
+import Support.FreeVars
hunk ./Main.hs 39
-import FreeVars
+import Support.FreeVars
hunk ./Support/FreeVars.hs 2
-module FreeVars where
+module Support.FreeVars where
hunk ./Support/ShowTable.hs 1
+module Support.ShowTable where
+
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+
+class ShowTable a where
+    showTablePairs :: a -> [(String,String)]
+
+instance (Show a,Show b) => ShowTable [(a,b)] where
+    showTablePairs xs = [ (show x,show y) | (x,y) <- xs ]
+
+instance (Show a,Show b) => Map.Map a b where
+    showTablePairs xs = [ (show x,show y) | (x,y) <- Map.toList xs ]
+
+instance Show a => Set.Set a where
+    showTablePairs xs = [ (show x,"") | x <- Set.toList xs ]
+
+
+printTable :: ShowTable a => String -> a -> IO ()
+printTable title x = do
+    unless (null title) $ putStrLn (title ++ ":")
+    mapM_ putStrLn [ "  " ++ x ++ " - " ++ y | (x,y) <- showTablePairs x]