[move Info and add type indexed binary instance for it
John Meacham <john@repetae.net>**20050923001301] adddir ./Info
move ./Info.hs ./Info/Info.hs
addfile ./Info/Binary.hs
addfile ./Info/Types.hs
hunk ./E/CPR.hs 12
-import qualified Info
+import qualified Info.Info as Info
hunk ./E/E.hs 21
-import qualified Info
+import qualified Info.Info as Info
hunk ./E/SSimplify.hs 26
-import qualified Info
+import qualified Info.Info as Info
hunk ./Info/Binary.hs 1
+module Info.Binary() where
+
+import Binary
+import Info.Info
+import Atom
+import PackedString
+import qualified Data.Set as Set
+import qualified Data.Map as Map
+import Info.Types
+import Data.Dynamic
+import GenUtil
+
+
+data Binable = forall a . (Typeable a, Binary a) => Binable a
+
+u :: (Typeable a, Binary a) => a
+u = u
+
+cb x = (packString (show (toDyn x)), Binable x)
+
+binTable = Map.fromList [
+    cb (u :: Arity),
+    cb (u :: Properties),
+    cb (u :: Atom)
+    ]
+
+
+putDyn :: BinHandle -> (Dynamic,Binable) -> IO ()
+putDyn h (d,Binable (_::a)) = put_ h (fromDyn d (error (show d)) :: a)
+
+-- = case Map.lookup (packString (show d)) of
+--    Just (Binable (x::a)) -> put_ h (case fromDynamic d of Just x -> x :: a)
+--    Nothing -> return ()
+
+
+getDyn h = do
+    (ps::PackedString) <- get h
+    b <- Map.lookup ps binTable
+    case b of
+        (Binable (_ :: a)) -> ((get h :: IO a) >>= return . toDyn)
+
+instance Binary Info where
+    put_ h (Info ds) = do
+        let ds' = concatMap (\d -> do x <- Map.lookup (packString $ show d) binTable ; return (d,x))  ds
+        put_ h (length ds')
+        mapM_ (putDyn h) ds'
+    get h = do
+        (n::Int) <- get h
+        xs <- replicateM n (getDyn h)
+        return (Info xs)
+
+
+
+
+
hunk ./Info/Info.hs 1
-module Info where
+module Info.Info where
hunk ./Info/Info.hs 9
+import Atom
hunk ./Info/Info.hs 47
-fetch info = maybe mempty id  (Info.lookup info)
+fetch info = maybe mempty id  (Info.Info.lookup info)
hunk ./Info/Types.hs 1
+-- | some useful types to use in Info's that don't really fit anywhere else
+module Info.Types where
+
+import qualified Data.Set as Set
+import Atom
+import Binary
+import Data.Dynamic
+import MapBinaryInstance
+
+-- | list of properties of a function, such as specified by use pragmas or options
+newtype Properties = Properties (Set.Set Atom)
+    deriving(Typeable,Show,Binary)
+
+-- | how many manifest lambdas are in a functions definition
+newtype Arity = Arity Int
+    deriving(Typeable,Show,Ord,Eq,Num,Binary)
+
+
+
+
hunk ./Main.hs 53
-import qualified Info
+import qualified Info.Info as Info
hunk ./Main.hs 56
+import Info.Binary()
hunk ./MapBinaryInstance.hs 5
-import Data.FiniteMap
+--import Data.FiniteMap
hunk ./MapBinaryInstance.hs 7
+import Data.Set as Set
hunk ./MapBinaryInstance.hs 20
+{-
hunk ./MapBinaryInstance.hs 24
+-}
+
+instance (Ord a,Binary a) => Binary (Set a) where
+    put_ bh x = do
+        put_ bh (Set.size x)
+        mapM_ (put_ bh) (Set.toList x)
+    get bh = do
+        (sz::Int) <- get bh
+        ls <- replicateM sz (get bh)
+        return (Set.fromList ls)
+        --get bh >>= return . Map.fromList
hunk ./SelfTest.hs 12
-import Info
+import Info.Info as Info