[add self test for binary, fix Info binary instance, add info table to tvr binary instance
John Meacham <john@repetae.net>**20050923004813] hunk ./E/E.hs 21
+import Info.Binary()
hunk ./E/E.hs 110
-    put_ bh (TVr 0 e _) = do
+    put_ bh (TVr { tvrIdent = 0, tvrType =  e, tvrInfo = nf} ) = do
hunk ./E/E.hs 113
-    put_ bh (TVr (i) e _) | Just x <- intToAtom i = do
+        put_ bh nf
+    put_ bh (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) | Just x <- intToAtom i = do
hunk ./E/E.hs 117
-    put_ bh (TVr (i) e _) = do
+        put_ bh nf
+    put_ bh (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) = do
+        unless (even i) $ fail "number not even"
hunk ./E/E.hs 122
+        put_ bh nf
hunk ./E/E.hs 126
+        nf <- get bh
hunk ./E/E.hs 128
-            TvrBinaryNone -> return $ TVr 0 e mempty
-            TvrBinaryAtom a -> return $ TVr (atomIndex a) e mempty
-            TvrBinaryInt i -> return $ TVr (i) e mempty
+            TvrBinaryNone -> return $ TVr 0 e nf
+            TvrBinaryAtom a -> return $ TVr (atomIndex a) e nf
+            TvrBinaryInt i -> return $ TVr (i) e nf
+
hunk ./Info/Binary.hs 7
-import qualified Data.Set as Set
hunk ./Info/Binary.hs 27
-putDyn :: BinHandle -> (Dynamic,Binable) -> IO ()
-putDyn h (d,Binable (_::a)) = put_ h (fromDyn d (error (show d)) :: a)
+putDyn :: BinHandle -> (PackedString,Dynamic,Binable) -> IO ()
+putDyn h (ps,d,Binable (_::a)) = do
+    put_ h ps
+    put_ h (fromDyn d (error (show d)) :: a)
hunk ./Info/Binary.hs 45
-        let ds' = concatMap (\d -> do x <- Map.lookup (packString $ show d) binTable ; return (d,x))  ds
+        let ds' = concatMap (\d -> do
+                let ps = packString $ show d
+                x <- Map.lookup ps binTable
+                return (ps,d,x)
+              )  ds
hunk ./Info/Info.hs 18
+instance Show Info where
+    show (Info ds) = show ds
+
hunk ./Main.hs 56
-import Info.Binary()
hunk ./SelfTest.hs 15
+import Binary
+import Info.Binary()
+import Info.Types
+import System.IO
+import E.E
hunk ./SelfTest.hs 33
+    testBinary
hunk ./SelfTest.hs 98
+
+putFile fn a = do
+    h <- openBinaryFile fn WriteMode
+    bh <- openBinIO h
+    put_ bh a
+    hClose h
+
+getFile fn = do
+    h <- openBinaryFile fn ReadMode
+    bh <- openBinIO h
+    b <- get bh
+    hClose h
+    return b
+
+
+testBinary = do
+    let test = ("hello",3::Int)
+        fn = "/tmp/jhc.test.bin"
+    putStrLn "Testing Binary"
+    putFile fn test
+    x <- getFile fn
+    if (x /= test) then fail "Test Failed" else return ()
+    let fn = "/tmp/jhc.info.bin"
+        t = Arity 3
+        nf = (Info.insert "food" $ Info.insert t mempty)
+    print nf
+    putFile fn nf
+    x <- getFile fn
+    print x
+    z <- Info.lookup x
+    if (z /= t) then fail "Info Test Failed" else return ()
+
+
+
+
+
+