[switch to Data.Binary for serialization, use ZLib to compress ho and hl files
John Meacham <john@repetae.net>**20070126090940] hunk ./Atom.hs 22
+import Data.Binary
hunk ./Atom.hs 128
+instance Binary Atom where
+    get = do fmap (unsafePerformIO . fromPackedStringIO) get
+    put a = put (toPackedString a)
+
hunk ./Binary.hs 1
-{-# OPTIONS_GHC -funbox-strict-fields -fallow-overlapping-instances #-}
---
--- (c) The University of Glasgow 2002
---
--- Binary I/O library, with special tweaks for GHC
---
--- Based on the nhc98 Binary library, which is copyright
--- (c) Malcolm Wallace and Colin Runciman, University of York, 1998.
--- Under the terms of the license for that software, we must tell you
--- where you can obtain the original version of the Binary library, namely
---     http://www.cs.york.ac.uk/fp/nhc98/
-
--- with modifications by John Meacham for jhc
-
-module Binary
-  ( {-class-} Binary(..),
-    {-type-}  BinHandle,
-
-   openBinIO,
-
-   -- for writing instances:
-   putByte,
-   getByte,
-
-   getNList,
-   putNList,
-
-   getN8List,
-   putN8List,
-
-   -- lazy Bin I/O
-   lazyGet,
-   lazyPut,
-
-
-  ) where
-
-
-import Data.Array.IO
-import Data.Array.Base
-import Data.Bits
-import System.Time
-import Foreign.Storable
-import Data.Int
-import Data.Word
-import Data.Char		( ord, chr )
-import Control.Monad
-import System.IO as IO
-import System.IO.Unsafe		( unsafeInterleaveIO )
-import GHC.Real			( Ratio(..) )
-import GHC.Exts
-import GHC.IOBase	 	( IO(..) )
-import GHC.Word			( Word8(..) )
-import PackedString
-import Atom
-import Time
-import Data.Array.IArray
-
-
-
----------------------------------------------------------------
---		BinHandle
----------------------------------------------------------------
-
-data BinHandle = BinHandle {
-    off_r :: !FastMutInt,
-    target_r :: !IO.Handle
-    }
-
-
----------------------------------------------------------------
---		Bin
----------------------------------------------------------------
-
-newtype Bin a = BinPtr Int
-  deriving (Eq, Ord, Show, Bounded)
-
-castBin :: Bin a -> Bin b
-castBin (BinPtr i) = BinPtr i
-
----------------------------------------------------------------
---		class Binary
----------------------------------------------------------------
-
-class Binary a where
-    put_   :: BinHandle -> a -> IO ()
-    get    :: BinHandle -> IO a
-
-putAt  :: Binary a => BinHandle -> Bin a -> a -> IO ()
-putAt bh p x = do seekBin bh p; put_ bh x; return ()
-
-getAt  :: Binary a => BinHandle -> Bin a -> IO a
-getAt bh p = do seekBin bh p; get bh
-
-
-openBinIO :: IO.Handle -> IO BinHandle
-openBinIO h = do
-  r <- newFastMutInt
-  writeFastMutInt r 0
-  hSetBinaryMode h True
-  hSetBuffering h (BlockBuffering Nothing)
-  return (BinHandle r (h))
-
-
-tellBin :: BinHandle -> IO (Bin a)
-tellBin (BinHandle r _)   = do ix <- readFastMutInt r; return (BinPtr ix)
-
-seekBin :: BinHandle -> Bin a -> IO ()
-seekBin (BinHandle ix_r (h)) (BinPtr p) = do
-  writeFastMutInt ix_r p
-  hSeek h AbsoluteSeek (fromIntegral p)
-
-isEOFBin :: BinHandle -> IO Bool
-isEOFBin (BinHandle _ (h)) = hIsEOF h
-
-
-
--- -----------------------------------------------------------------------------
--- Low-level reading/writing of bytes
-
-putWord8 :: BinHandle -> Word8 -> IO ()
-putWord8 (BinHandle ix_r (h)) w = do
-    hPutChar h (chr (fromIntegral w))	-- XXX not really correct
-    ix <- readFastMutInt ix_r
-    writeFastMutInt ix_r (ix+1)
-    return ()
-
-getWord8 :: BinHandle -> IO Word8
-getWord8 (BinHandle ix_r (h)) = do
-    ix <- readFastMutInt ix_r
-    writeFastMutInt ix_r (ix+1)
-    c <- hGetChar h
-    return $! (fromIntegral (ord c))	-- XXX not really correct
-
-{-# INLINE putByte #-}
-putByte :: BinHandle -> Word8 -> IO ()
-putByte bh w = putWord8 bh w
-
-{-# INLINE getByte #-}
-getByte :: BinHandle -> IO Word8
-getByte = getWord8
-
-
--- These do not increment the counter
-
-{-# INLINE putByteIO #-}
-putByteIO :: FastMutInt -> Handle -> Word8 -> IO ()
-putByteIO ix_r h w = do
-    hPutChar h (chr (fromIntegral w))	-- XXX not really correct
-    return ()
-
-{-# INLINE getByteIO #-}
-getByteIO :: FastMutInt -> Handle -> IO Word8
-getByteIO ix_r h = do
-    c <- hGetChar h
-    return $! (fromIntegral (ord c))	-- XXX not really correct
-
-{-# INLINE increment #-}
-increment :: FastMutInt -> Int -> IO ()
-increment ix i = do
-    v <- readFastMutInt ix
-    writeFastMutInt ix (v + i)
-
-
--- -----------------------------------------------------------------------------
--- Primitve Word writes
-
-instance Binary Word8 where
-  put_ = putWord8
-  get  = getWord8
-
-instance Binary Word16 where
-  put_ h w = do -- XXX too slow.. inline putWord8?
-    w <- return $ fromIntegral w
-    putByte h (fromIntegral ((w `unsafeShiftR` 8) .&. 0xff))
-    putByte h (fromIntegral (w .&. 0xff))
-  get h = do
-    w1 <- getWord8 h
-    w2 <- getWord8 h
-    return $! fromIntegral ((fromIntegral w1 `unsafeShiftL` 8) .|. fromIntegral w2)
-
-unsafeShiftL (W# a) (I# b) = (W# (a `uncheckedShiftL#` b))
-unsafeShiftR (W# a) (I# b) = (W# (a `uncheckedShiftRL#` b))
-
-instance Binary Word32 where
-  put_ (BinHandle ix (h)) w = do
-    w <- return $ fromIntegral w
-    putByteIO ix h (fromIntegral ((w `unsafeShiftR` 24) .&. 0xff))
-    putByteIO ix h (fromIntegral ((w `unsafeShiftR` 16) .&. 0xff))
-    putByteIO ix h (fromIntegral ((w `unsafeShiftR` 8)  .&. 0xff))
-    putByteIO ix h (fromIntegral (w .&. 0xff))
-    increment ix 4
-  get (BinHandle ix (h)) = do
-    w1 <- getByteIO ix h
-    w2 <- getByteIO ix h
-    w3 <- getByteIO ix h
-    w4 <- getByteIO ix h
-    increment ix 4
-    return $! fromIntegral $ ((fromIntegral w1 `unsafeShiftL` 24) .|.
-	       (fromIntegral w2 `unsafeShiftL` 16) .|.
-	       (fromIntegral w3 `unsafeShiftL`  8) .|.
-	       (fromIntegral w4))
-
-
-{-
-instance Binary Word64 where
-  put_ h w = do
-    putByte h (fromIntegral (w `unsafeShiftR` 56))
-    putByte h (fromIntegral ((w `unsafeShiftR` 48) .&. 0xff))
-    putByte h (fromIntegral ((w `unsafeShiftR` 40) .&. 0xff))
-    putByte h (fromIntegral ((w `unsafeShiftR` 32) .&. 0xff))
-    putByte h (fromIntegral ((w `unsafeShiftR` 24) .&. 0xff))
-    putByte h (fromIntegral ((w `unsafeShiftR` 16) .&. 0xff))
-    putByte h (fromIntegral ((w `unsafeShiftR`  8) .&. 0xff))
-    putByte h (fromIntegral (w .&. 0xff))
-  get h = do
-    w1 <- getWord8 h
-    w2 <- getWord8 h
-    w3 <- getWord8 h
-    w4 <- getWord8 h
-    w5 <- getWord8 h
-    w6 <- getWord8 h
-    w7 <- getWord8 h
-    w8 <- getWord8 h
-    return $! ((fromIntegral w1 `unsafeShiftL` 56) .|.
-	       (fromIntegral w2 `unsafeShiftL` 48) .|.
-	       (fromIntegral w3 `unsafeShiftL` 40) .|.
-	       (fromIntegral w4 `unsafeShiftL` 32) .|.
-	       (fromIntegral w5 `unsafeShiftL` 24) .|.
-	       (fromIntegral w6 `unsafeShiftL` 16) .|.
-	       (fromIntegral w7 `unsafeShiftL`  8) .|.
-	       (fromIntegral w8))
--}
-
--- -----------------------------------------------------------------------------
--- Primitve Int writes
-
-instance Binary Int8 where
-  put_ h w = put_ h (fromIntegral w :: Word8)
-  get h    = do w <- get h; return $! (fromIntegral (w::Word8))
-
-instance Binary Int16 where
-  put_ h w = put_ h (fromIntegral w :: Word16)
-  get h    = do w <- get h; return $! (fromIntegral (w::Word16))
-
-instance Binary Int32 where
-  put_ h w = put_ h (fromIntegral w :: Word32)
-  get h    = do w <- get h; return $! (fromIntegral (w::Word32))
-
-{-
-instance Binary Int64 where
-  put_ h w = put_ h (fromIntegral w :: Word64)
-  get h    = do w <- get h; return $! (fromIntegral (w::Word64))
--}
--- -----------------------------------------------------------------------------
--- Instances for standard types
-
-instance Binary () where
-    put_ bh () = return ()
-    get  _     = return ()
---    getF bh p  = case getBitsF bh 0 p of (_,b) -> ((),b)
-
-instance Binary Bool where
-    put_ bh b = putByte bh (fromIntegral (fromEnum b))
-    get  bh   = do x <- getWord8 bh; return $! (toEnum (fromIntegral x))
---    getF bh p = case getBitsF bh 1 p of (x,b) -> (toEnum x,b)
-
-instance Binary Char where
-    put_  bh c = put_ bh (fromIntegral (ord c) :: Word32)
-    get  bh   = do x <- get bh; return $! (chr (fromIntegral (x :: Word32)))
---    getF bh p = case getBitsF bh 8 p of (x,b) -> (toEnum x,b)
-
--- portability demands ints restricted to 32 bits
-instance Binary Int where
-    put_ bh i = put_ bh (fromIntegral i :: Int32)
-    get  bh = do
-	x <- get bh
-	return $! (fromIntegral (x :: Int32))
-
-instance Binary Word where
-    put_ bh i = put_ bh (fromIntegral i :: Word32)
-    get  bh = do
-	x <- get bh
-	return $! (fromIntegral (x :: Word32))
-
-instance Binary ClockTime where
-    put_ bh (TOD x y) = put_ bh x >> put_ bh y
-    get bh = do
-        x <- get bh
-        y <- get bh
-        return $ TOD x y
-
-
-instance Binary PackedString where
-    put_ bh (PS a) = put_ bh a
-    get bh = fmap PS $ get bh
-
-
--- | put length prefixed list.
-putNList :: Binary a => BinHandle -> [a] -> IO ()
-putNList bh xs = do
-    put_ bh (length xs)
-    mapM_ (put_ bh) xs
-
--- | get length prefixed list.
-getNList :: Binary a => BinHandle -> IO [a]
-getNList bh = do
-    n <- get bh
-    sequence $ replicate n (get bh)
-
--- | put length prefixed list.
-putN8List :: Binary a => BinHandle -> [a] -> IO ()
-putN8List bh xs = do
-    let len = length xs
-    when (length xs > 255) $ fail "putN8List, list is too long"
-    putWord8 bh (fromIntegral len)
-    mapM_ (put_ bh) xs
-
--- | get length prefixed list.
-getN8List :: Binary a => BinHandle -> IO [a]
-getN8List bh = do
-    n <- getWord8 bh
-    sequence $ replicate (fromIntegral n) (get bh)
-
-instance Binary a => Binary [a] where
-    put_ bh []     = putByte bh 0
-    put_ bh (x:xs) = do putByte bh 1; put_ bh x; put_ bh xs
-    get bh         = do h <- getWord8 bh
-                        case h of
-                          0 -> return []
-                          1 -> do x  <- get bh
-                                  xs <- get bh
-                                  return (x:xs)
-
-instance (Binary a, Binary b) => Binary (a,b) where
-    put_ bh (a,b) = do put_ bh a; put_ bh b
-    get bh        = do a <- get bh
-                       b <- get bh
-                       return (a,b)
-
-instance (Binary a, Binary b, Binary c) => Binary (a,b,c) where
-    put_ bh (a,b,c) = do put_ bh a; put_ bh b; put_ bh c
-    get bh          = do a <- get bh
-                         b <- get bh
-                         c <- get bh
-                         return (a,b,c)
-
-instance (Binary a, Binary b, Binary c, Binary d) => Binary (a,b,c,d) where
-    put_ bh (a,b,c,d) = do put_ bh a; put_ bh b; put_ bh c; put_ bh d
-    get bh          = do a <- get bh
-                         b <- get bh
-                         c <- get bh
-                         d <- get bh
-                         return (a,b,c,d)
-
-instance Binary a => Binary (Maybe a) where
-    put_ bh Nothing  = putByte bh 0
-    put_ bh (Just a) = do putByte bh 1; put_ bh a
-    get bh           = do
-        h <- getWord8 bh
-        case h of
-            0 -> return Nothing
-            1 -> do
-                x <- get bh
-                return (Just x)
-
-instance (Binary a, Binary b) => Binary (Either a b) where
-    put_ bh (Left  a) = do putByte bh 0; put_ bh a
-    put_ bh (Right b) = do putByte bh 1; put_ bh b
-    get bh            = do h <- getWord8 bh
-                           case h of
-                             0 -> do a <- get bh ; return (Left a)
-                             1 -> do b <- get bh ; return (Right b)
-
-
-
--- these flatten the start element. hope that's okay!
-instance Binary (UArray Int Word8) where
-    put_ bh@(BinHandle ix_r (h)) ua = do
-        let sz = rangeSize (Data.Array.Base.bounds ua)
-        put_ bh sz
-        ix <- readFastMutInt ix_r
-        ua <- unsafeThaw ua
-        hPutArray h ua sz
-        writeFastMutInt ix_r (ix + sz)
-    get bh@(BinHandle ix_r (h)) = do
-        sz <- get bh
-        ix <- readFastMutInt ix_r
-        ba <- newArray_ (0, sz - 1)
-        hGetArray h ba sz
-        writeFastMutInt ix_r (ix + sz)
-        ba <- unsafeFreeze ba
-        return ba
-
-toInts :: Integer -> [Int32]
-toInts n
-    | n == 0 = []
-    | otherwise = mkInt (n `mod` numInts):toInts (n `div` numInts)
-  where mkInt n | n > toInteger(maxBound::Int32) = fromInteger (n-numInts)
-		| otherwise = fromInteger n
-
-fromInts :: [Int32] -> Integer
-fromInts = foldr catInt 0
-    where catInt d n = (if d<0 then n+1 else n)*numInts + toInteger d
-
-numInts = toInteger (maxBound::Int32) - toInteger (minBound::Int32) + 1
-
-instance Binary Integer where
-    put_ bh i = do
-        if i < 0
-         then putByte bh 1 >> putNList bh (toInts $ negate i)
-         else putByte bh 0 >> putNList bh (toInts i)
-    get bh = do
-        b <- getByte bh
-        is <- getNList bh
-        case b of
-            1 -> return $ negate $ fromInts is
-            0 -> return $ fromInts is
-
-putByteArray :: BinHandle -> ByteArray# -> Int# -> IO ()
-putByteArray bh a s# = loop 0#
-  where loop n#
-	   | n# ==# s# = return ()
-	   | otherwise = do
-	   	putByte bh (indexByteArray a n#)
-		loop (n# +# 1#)
-
-getByteArray :: BinHandle -> Int -> IO ByteArray
-getByteArray bh (I# sz) = do
-  (MBA arr) <- newByteArray sz
-  let loop n
-	   | n ==# sz = return ()
-	   | otherwise = do
-		w <- getByte bh
-		writeByteArray arr n w
-		loop (n +# 1#)
-  loop 0#
-  freezeByteArray arr
-
-
-data ByteArray = BA ByteArray#
-data MBA = MBA (MutableByteArray# RealWorld)
-
-newByteArray :: Int# -> IO MBA
-newByteArray sz = IO $ \s ->
-  case newByteArray# sz s of { (# s, arr #) ->
-  (# s, MBA arr #) }
-
-freezeByteArray :: MutableByteArray# RealWorld -> IO ByteArray
-freezeByteArray arr = IO $ \s ->
-  case unsafeFreezeByteArray# arr s of { (# s, arr #) ->
-  (# s, BA arr #) }
-
-writeByteArray :: MutableByteArray# RealWorld -> Int# -> Word8 -> IO ()
-
-writeByteArray arr i (W8# w) = IO $ \s ->
-  case writeWord8Array# arr i w s of { s ->
-  (# s, () #) }
-
-indexByteArray a# n# = W8# (indexWord8Array# a# n#)
-
-instance (Integral a, Binary a) => Binary (Ratio a) where
-    put_ bh (a :% b) = do put_ bh a; put_ bh b
-    get bh = do a <- get bh; b <- get bh; return (a :% b)
---  #endif
-
-instance Binary (Bin a) where
-  put_ bh (BinPtr i) = put_ bh i
-  get bh = do i <- get bh; return (BinPtr i)
-
--- -----------------------------------------------------------------------------
--- Lazy reading/writing
-
-lazyPut :: Binary a => BinHandle -> a -> IO ()
-lazyPut bh a = do
-	-- output the obj with a ptr to skip over it:
-    pre_a <- tellBin bh
-    put_ bh pre_a	-- save a slot for the ptr
-    put_ bh a		-- dump the object
-    q <- tellBin bh 	-- q = ptr to after object
-    putAt bh pre_a q 	-- fill in slot before a with ptr to q
-    seekBin bh q	-- finally carry on writing at q
-
-lazyGet :: Binary a => BinHandle -> IO a
-lazyGet bh = do
-    p <- get bh		-- a BinPtr
-    p_a <- tellBin bh
-    a <- unsafeInterleaveIO (getAt bh p_a)
-    seekBin bh p -- skip over the object for now
-    return a
-
-
-instance Binary Atom where
-    get bh = do
-        ps <- get bh
-        a <- fromPackedStringIO ps
-        return a
-    put_ bh a = put_ bh (toPackedString a)
-
--- FastMutInt
-
-sSIZEOF_HSINT = sizeOf (undefined :: Int)
-
-data FastMutInt = FastMutInt (MutableByteArray# RealWorld)
-
-newFastMutInt :: IO FastMutInt
-newFastMutInt = IO $ \s ->
-  case newByteArray# size s of { (# s, arr #) ->
-  (# s, FastMutInt arr #) }
-  where I# size = sSIZEOF_HSINT
-
-{-# INLINE readFastMutInt  #-}
-readFastMutInt :: FastMutInt -> IO Int
-readFastMutInt (FastMutInt arr) = IO $ \s ->
-  case readIntArray# arr 0# s of { (# s, i #) ->
-  (# s, I# i #) }
-
-{-# INLINE writeFastMutInt  #-}
-writeFastMutInt :: FastMutInt -> Int -> IO ()
-writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s ->
-  case writeIntArray# arr 0# i s of { s ->
-  (# s, () #) }
-
rmfile ./Binary.hs
hunk ./C/FFI.hs 5
-import Binary
+import Data.Binary
hunk ./C/FFI.hs 12
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./C/FFI.hs 15
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./C/FFI.hs 22
-             {-! derive: GhcBinary !-}
+             {-! derive: Binary !-}
hunk ./C/FFI.hs 28
-    {-! derive: Monoid, GhcBinary !-}
+    {-! derive: Monoid, Binary !-}
hunk ./C/FFI.hs 38
-             {-! derive: GhcBinary !-}
+             {-! derive: Binary !-}
hunk ./C/FFI.hs 42
-             {-! derive: GhcBinary !-}
+             {-! derive: Binary !-}
hunk ./C/Prims.hs 6
-import Binary
+import Data.Binary
hunk ./C/Prims.hs 28
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./C/Prims.hs 69
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./C/Prims.hs 73
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./C/Prims.hs 135
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./DataConstructors.hs 43
-import Binary
+import Data.Binary
hunk ./DataConstructors.hs 60
-import MapBinaryInstance()
+import MapBinaryInstance
hunk ./DataConstructors.hs 115
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./DataConstructors.hs 125
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./DataConstructors.hs 141
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./DataConstructors.hs 148
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./DataConstructors.hs 171
-    {-! derive: GhcBinary, Monoid !-}
+    {-! derive: Monoid !-}
+
+instance Binary DataTable where
+    put (DataTable dt) = putMap dt
+    get = fmap DataTable getMap
hunk ./E/Binary.hs 3
-import E.Type
-import E.FreeVars(caseUpdate)
-import {-# SOURCE #-} Info.Binary(putInfo,getInfo)
-import Binary
hunk ./E/Binary.hs 4
+import Data.Binary
+import E.FreeVars(caseUpdate)
+import E.Type
hunk ./E/Binary.hs 8
+import Name.Binary
+import {-# SOURCE #-} Info.Binary(putInfo,getInfo)
hunk ./E/Binary.hs 11
-{-!derive: is !-}
hunk ./E/Binary.hs 16
-    put_ bh (TVr { tvrIdent = 0, tvrType =  e, tvrInfo = nf} ) = do
-        put_ bh (TvrBinaryNone)
-        put_ bh e
-        putInfo bh nf
-    put_ bh (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) | Just x <- intToAtom i = do
-        put_ bh (TvrBinaryAtom x)
-        put_ bh e
-        putInfo bh nf
-    put_ bh (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) = do
+    put (TVr { tvrIdent = 0, tvrType =  e, tvrInfo = nf} ) = do
+        put (TvrBinaryNone)
+        put e
+        putInfo nf
+    put (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) | Just x <- intToAtom i = do
+        put (TvrBinaryAtom x)
+        put e
+        putInfo nf
+    put (TVr { tvrIdent = i, tvrType =  e, tvrInfo = nf}) = do
hunk ./E/Binary.hs 26
-        put_ bh (TvrBinaryInt i)
-        put_ bh e
-        putInfo bh nf
-    get bh = do
-        (x ) <- get bh
-        e <- get bh
-        nf <- getInfo bh
+        put (TvrBinaryInt i)
+        put e
+        putInfo nf
+    get  = do
+        (x ) <- get
+        e <- get
+        nf <- getInfo
hunk ./E/Binary.hs 38
+instance Binary TvrBinary where
+    put TvrBinaryNone = do putWord8  0
+    put (TvrBinaryAtom aa) = do
+        putWord8 1
+        put aa
+    put (TvrBinaryInt ab) = do
+	    putWord8 2
+	    put ab
+    get = do
+	    h <- getWord8
+	    case h of
+	      0 -> do return TvrBinaryNone
+	      1 -> do
+		    aa <- get
+		    return (TvrBinaryAtom aa)
+	      2 -> do
+		    ab <- get
+		    return (TvrBinaryInt ab)
+	      _ -> fail "invalid binary data found"
hunk ./E/Binary.hs 58
-instance Binary RuleType where
-    put_ bh RuleSpecialization = do
-	    putByte bh 0
-    put_ bh RuleUser = do
-	    putByte bh 1
-    put_ bh RuleCatalyst = do
-	    putByte bh 2
-    get bh = do
-	    h <- getByte bh
+instance Data.Binary.Binary RuleType where
+    put RuleSpecialization = do
+	    Data.Binary.putWord8 0
+    put RuleUser = do
+	    Data.Binary.putWord8 1
+    put RuleCatalyst = do
+	    Data.Binary.putWord8 2
+    get = do
+	    h <- Data.Binary.getWord8
hunk ./E/Binary.hs 76
-instance Binary Rule where
-    put_ bh (Rule aa ab ac ad ae af ag ah) = do
-	    put_ bh aa
-	    put_ bh ab
-	    put_ bh ac
-	    put_ bh ad
-	    put_ bh ae
-	    put_ bh af
-	    put_ bh ag
-	    put_ bh ah
-    get bh = do
-    aa <- get bh
-    ab <- get bh
-    ac <- get bh
-    ad <- get bh
-    ae <- get bh
-    af <- get bh
-    ag <- get bh
-    ah <- get bh
+instance Data.Binary.Binary Rule where
+    put (Rule aa ab ac ad ae af ag ah) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+	    Data.Binary.put ac
+	    Data.Binary.put ad
+	    Data.Binary.put ae
+	    Data.Binary.put af
+	    Data.Binary.put ag
+	    Data.Binary.put ah
+    get = do
+    aa <- get
+    ab <- get
+    ac <- get
+    ad <- get
+    ae <- get
+    af <- get
+    ag <- get
+    ah <- get
hunk ./E/Binary.hs 97
-instance (Binary e,Binary t) => Binary (Lit e t) where
-    put_ bh (LitInt aa ab) = do
-	    putByte bh 0
-	    put_ bh aa
-	    put_ bh ab
-    put_ bh (LitCons ac ad ae af) = do
-	    putByte bh 1
-	    put_ bh ac
-	    put_ bh ad
-	    put_ bh ae
-	    put_ bh af
-    get bh = do
-	    h <- getByte bh
+instance Data.Binary.Binary ARules where
+    put (ARules aa ab) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+    get = do
+    aa <- get
+    ab <- get
+    return (ARules aa ab)
+
+
+instance (Data.Binary.Binary e,
+	  Data.Binary.Binary t) => Data.Binary.Binary (Lit e t) where
+    put (LitInt aa ab) = do
+	    Data.Binary.putWord8 0
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+    put (LitCons ac ad ae af) = do
+	    Data.Binary.putWord8 1
+	    Data.Binary.put ac
+	    Data.Binary.put ad
+	    Data.Binary.put ae
+	    Data.Binary.put af
+    get = do
+	    h <- Data.Binary.getWord8
hunk ./E/Binary.hs 123
-		    aa <- get bh
-		    ab <- get bh
+		    aa <- Data.Binary.get
+		    ab <- Data.Binary.get
hunk ./E/Binary.hs 127
-		    ac <- get bh
-		    ad <- get bh
-		    ae <- get bh
-		    af <- get bh
+		    ac <- Data.Binary.get
+		    ad <- Data.Binary.get
+		    ae <- Data.Binary.get
+		    af <- Data.Binary.get
hunk ./E/Binary.hs 135
-instance Binary ESort where
-    put_ bh EStar = do
-	    putByte bh 0
-    put_ bh EBang = do
-	    putByte bh 1
-    put_ bh EHash = do
-	    putByte bh 2
-    put_ bh ETuple = do
-	    putByte bh 3
-    put_ bh EHashHash = do
-	    putByte bh 4
-    put_ bh EStarStar = do
-	    putByte bh 5
-    put_ bh (ESortNamed aa) = do
-	    putByte bh 6
-	    put_ bh aa
-    get bh = do
-	    h <- getByte bh
+instance Data.Binary.Binary ESort where
+    put EStar = do
+	    Data.Binary.putWord8 0
+    put EBang = do
+	    Data.Binary.putWord8 1
+    put EHash = do
+	    Data.Binary.putWord8 2
+    put ETuple = do
+	    Data.Binary.putWord8 3
+    put EHashHash = do
+	    Data.Binary.putWord8 4
+    put EStarStar = do
+	    Data.Binary.putWord8 5
+    put (ESortNamed aa) = do
+	    Data.Binary.putWord8 6
+	    Data.Binary.put aa
+    get = do
+	    h <- Data.Binary.getWord8
hunk ./E/Binary.hs 167
-		    aa <- get bh
+		    aa <- Data.Binary.get
hunk ./E/Binary.hs 172
-instance Binary E where
-    put_ bh (EAp aa ab) = do
-	    putByte bh 0
-	    put_ bh aa
-	    put_ bh ab
-    put_ bh (ELam ac ad) = do
-	    putByte bh 1
-	    put_ bh ac
-	    put_ bh ad
-    put_ bh (EPi ae af) = do
-	    putByte bh 2
-	    put_ bh ae
-	    put_ bh af
-    put_ bh (EVar ag) = do
-	    putByte bh 3
-	    put_ bh ag
-    put_ bh Unknown = do
-	    putByte bh 4
-    put_ bh (ESort ah) = do
-	    putByte bh 5
-	    put_ bh ah
-    put_ bh (ELit ai) = do
-	    putByte bh 6
-	    put_ bh ai
-    put_ bh (ELetRec aj ak) = do
-	    putByte bh 7
-	    put_ bh aj
-	    put_ bh ak
-    put_ bh (EPrim al am an) = do
-	    putByte bh 8
-	    put_ bh al
-	    put_ bh am
-	    put_ bh an
-    put_ bh (EError ao ap) = do
-	    putByte bh 9
-	    put_ bh ao
-	    put_ bh ap
-    put_ bh (ECase aq ar as at au fv) = do
-	    putByte bh 10
-	    put_ bh aq
-	    put_ bh ar
-	    put_ bh as
-	    put_ bh at
-	    put_ bh au
-    get bh = do
-	    h <- getByte bh
+instance Data.Binary.Binary E where
+    put (EAp aa ab) = do
+	    Data.Binary.putWord8 0
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+    put (ELam ac ad) = do
+	    Data.Binary.putWord8 1
+	    Data.Binary.put ac
+	    Data.Binary.put ad
+    put (EPi ae af) = do
+	    Data.Binary.putWord8 2
+	    Data.Binary.put ae
+	    Data.Binary.put af
+    put (EVar ag) = do
+	    Data.Binary.putWord8 3
+	    Data.Binary.put ag
+    put Unknown = do
+	    Data.Binary.putWord8 4
+    put (ESort ah) = do
+	    Data.Binary.putWord8 5
+	    Data.Binary.put ah
+    put (ELit ai) = do
+	    Data.Binary.putWord8 6
+	    Data.Binary.put ai
+    put (ELetRec aj ak) = do
+	    Data.Binary.putWord8 7
+	    Data.Binary.put aj
+	    Data.Binary.put ak
+    put (EPrim al am an) = do
+	    Data.Binary.putWord8 8
+	    Data.Binary.put al
+	    Data.Binary.put am
+	    Data.Binary.put an
+    put (EError ao ap) = do
+	    Data.Binary.putWord8 9
+	    Data.Binary.put ao
+	    Data.Binary.put ap
+    put (ECase aq ar as at au av) = do
+	    Data.Binary.putWord8 10
+	    Data.Binary.put aq
+	    Data.Binary.put ar
+	    Data.Binary.put as
+	    Data.Binary.put at
+	    Data.Binary.put au
+	    Data.Binary.put av
+    get = do
+	    h <- Data.Binary.getWord8
hunk ./E/Binary.hs 221
-		    aa <- get bh
-		    ab <- get bh
+		    aa <- Data.Binary.get
+		    ab <- Data.Binary.get
hunk ./E/Binary.hs 225
-		    ac <- get bh
-		    ad <- get bh
+		    ac <- Data.Binary.get
+		    ad <- Data.Binary.get
hunk ./E/Binary.hs 229
-		    ae <- get bh
-		    af <- get bh
+		    ae <- Data.Binary.get
+		    af <- Data.Binary.get
hunk ./E/Binary.hs 233
-		    ag <- get bh
+		    ag <- Data.Binary.get
hunk ./E/Binary.hs 238
-		    ah <- get bh
+		    ah <- Data.Binary.get
hunk ./E/Binary.hs 241
-		    ai <- get bh
+		    ai <- Data.Binary.get
hunk ./E/Binary.hs 244
-		    aj <- get bh
-		    ak <- get bh
+		    aj <- Data.Binary.get
+		    ak <- Data.Binary.get
hunk ./E/Binary.hs 248
-		    al <- get bh
-		    am <- get bh
-		    an <- get bh
+		    al <- Data.Binary.get
+		    am <- Data.Binary.get
+		    an <- Data.Binary.get
hunk ./E/Binary.hs 253
-		    ao <- get bh
-		    ap <- get bh
+		    ao <- Data.Binary.get
+		    ap <- Data.Binary.get
hunk ./E/Binary.hs 257
-		    aq <- get bh
-		    ar <- get bh
-		    as <- get bh
-		    at <- get bh
-		    au <- get bh
-		    return (caseUpdate $ ECase aq ar as at au undefined)
+		    aq <- Data.Binary.get
+		    ar <- Data.Binary.get
+		    as <- Data.Binary.get
+		    at <- Data.Binary.get
+		    au <- Data.Binary.get
+		    av <- Data.Binary.get
+		    return (ECase aq ar as at au av)
hunk ./E/Binary.hs 267
-instance (Binary e) => Binary (Alt e) where
-    put_ bh (Alt aa ab) = do
-	    put_ bh aa
-	    put_ bh ab
-    get bh = do
-    aa <- get bh
-    ab <- get bh
+
+instance (Data.Binary.Binary e) => Data.Binary.Binary (Alt e) where
+    put (Alt aa ab) = do
+	    Data.Binary.put aa
+	    Data.Binary.put ab
+    get = do
+    aa <- get
+    ab <- get
hunk ./E/Binary.hs 277
-instance Binary TvrBinary where
-    put_ bh TvrBinaryNone = do
-	    putByte bh 0
-    put_ bh (TvrBinaryAtom aa) = do
-	    putByte bh 1
-	    put_ bh aa
-    put_ bh (TvrBinaryInt ab) = do
-	    putByte bh 2
-	    put_ bh ab
-    get bh = do
-	    h <- getByte bh
-	    case h of
-	      0 -> do
-		    return TvrBinaryNone
-	      1 -> do
-		    aa <- get bh
-		    return (TvrBinaryAtom aa)
-	      2 -> do
-		    ab <- get bh
-		    return (TvrBinaryInt ab)
-	      _ -> fail "invalid binary data found"
hunk ./E/Binary.hs 278
---  Imported from other files :-
hunk ./E/CPR.hs 4
+import Data.Binary
hunk ./E/CPR.hs 9
-import Binary
hunk ./E/CPR.hs 34
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./E/Demand.hs 16
+import Data.Binary
hunk ./E/Demand.hs 24
-import Binary
hunk ./E/Demand.hs 45
-        {-! derive: GhcBinary !-}
+        {-! derive: Binary !-}
hunk ./E/Demand.hs 62
-        {-! derive: GhcBinary !-}
+        {-! derive: Binary !-}
hunk ./E/Demand.hs 66
-        {-! derive: GhcBinary !-}
+        {-! derive: Binary !-}
hunk ./E/Demand.hs 69
-        {-! derive: GhcBinary !-}
+        {-! derive: Binary !-}
hunk ./E/Demand.hs 72
-        {-! derive: GhcBinary !-}
+        {-! derive: Binary !-}
hunk ./E/Rules.hs 32
-import Binary
+import Data.Binary
hunk ./E/Rules.hs 84
-    put_ h (Rules mp) = putNList h (concat $ melems mp)
-    get h = do
-        rs <- getNList h
+    put (Rules mp) = put (concat $ melems mp)
+    get = do
+        rs <- get
hunk ./FrontEnd/Class.hs 28
-import Binary
+import Data.Binary
hunk ./FrontEnd/Class.hs 36
-import MapBinaryInstance()
+import MapBinaryInstance
hunk ./FrontEnd/Class.hs 63
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Class.hs 84
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Class.hs 124
-    deriving (Binary,HasSize)
+    deriving (HasSize)
+
+instance Binary ClassHierarchy where
+    get = fmap ClassHierarchy getMap
+    put (ClassHierarchy ch) = putMap ch
hunk ./FrontEnd/HsSyn.hs 6
-import Binary
+import Data.Binary
hunk ./FrontEnd/HsSyn.hs 42
-  {-! derive: is, update, GhcBinary !-}
+  {-! derive: is, update, Binary !-}
hunk ./FrontEnd/HsSyn.hs 57
-    get bh = do
-        ps <- get bh
+    get = do
+        ps <- get
hunk ./FrontEnd/HsSyn.hs 60
-    put_ bh (Module n) = put_ bh (packString n)
+    put (Module n) = put (packString n)
hunk ./FrontEnd/HsSyn.hs 63
-    get bh = do
-        ps <- get bh
+    get = do
+        ps <- get
hunk ./FrontEnd/HsSyn.hs 66
-    put_ bh (HsIdent n) = put_ bh (packString n)
+    put (HsIdent n) = put (packString n)
hunk ./FrontEnd/HsSyn.hs 123
-  {-! derive: GhcBinary !-}
+  {-! derive: Binary !-}
hunk ./FrontEnd/HsSyn.hs 269
-  {-! derive: GhcBinary !-}
+  {-! derive: Binary !-}
hunk ./FrontEnd/HsSyn.hs 291
-  {-! derive: GhcBinary, is !-}
+  {-! derive: Binary, is !-}
hunk ./FrontEnd/HsSyn.hs 298
-  {-! derive: GhcBinary, update !-}
+  {-! derive: Binary, update !-}
hunk ./FrontEnd/HsSyn.hs 311
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/HsSyn.hs 414
-  {-! derive: GhcBinary !-}
+  {-! derive: Binary !-}
hunk ./FrontEnd/Infix.hs 21
-import Binary
+import Data.Binary
hunk ./FrontEnd/Infix.hs 23
+import qualified Data.Map as Map
+
hunk ./FrontEnd/Infix.hs 27
-import MapBinaryInstance()
+import MapBinaryInstance
hunk ./FrontEnd/Infix.hs 29
-import qualified Data.Map as Map
hunk ./FrontEnd/Infix.hs 38
-    deriving(Monoid,Binary,HasSize)
+    deriving(Monoid,HasSize)
hunk ./FrontEnd/Infix.hs 40
+instance Binary FixityMap where
+    put (FixityMap ts) = putMap ts
+    get = fmap FixityMap getMap
hunk ./FrontEnd/KindInfer.hs 33
-import Binary
+import Data.Binary
hunk ./FrontEnd/KindInfer.hs 44
-import MapBinaryInstance()
+import MapBinaryInstance
hunk ./FrontEnd/KindInfer.hs 58
-        {-!derive: Monoid, GhcBinary !-}
+        {-!derive: Monoid !-}
+
+instance Binary KindEnv where
+    put KindEnv { kindEnv = a, kindEnvAssocs = b, kindEnvClasses = c } = putMap a >> putMap b >> putMap c
+    get = do
+        a <- getMap
+        b <- getMap
+        c <- getMap
+        return KindEnv { kindEnv = a, kindEnvAssocs = b, kindEnvClasses = c }
hunk ./FrontEnd/Representation.hs 42
-import Binary
+import Data.Binary
hunk ./FrontEnd/Representation.hs 62
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 73
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 77
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 109
-    {-  derive: GhcBinary -}
+    {-  derive: Binary -}
hunk ./FrontEnd/Representation.hs 145
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 165
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 170
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Representation.hs 190
-    put_ bh (Tyvar aa ab ac) = do
-        put_ bh aa
-        put_ bh ab
-        put_ bh ac
-    get bh = do
-        aa <- get bh
-        ab <- get bh
-        ac <- get bh
+    put (Tyvar aa ab ac) = do
+        put aa
+        put ab
+        put ac
+    get = do
+        aa <- get
+        ab <- get
+        ac <- get
hunk ./FrontEnd/SrcLoc.hs 10
-import Binary
+import Data.Binary
hunk ./FrontEnd/SrcLoc.hs 15
-    {-! derive: update, GhcBinary !-}
+    {-! derive: update, Binary !-}
hunk ./FrontEnd/Tc/Kind.hs 19
-import Binary
+import Data.Binary
hunk ./FrontEnd/Tc/Kind.hs 56
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Tc/Kind.hs 68
-    {-! derive: GhcBinary !-}
+    {-! derive: Binary !-}
hunk ./FrontEnd/Tc/Kind.hs 118
-    put_ _ _ = return ()
-    get _ = return (error "Binary.Kindvar.get")
+    put _ = return ()
+    get = return (error "Binary.Kindvar.get")
hunk ./FrontEnd/TypeSynonyms.hs 12
+import Data.Binary
hunk ./FrontEnd/TypeSynonyms.hs 16
-import Binary
hunk ./FrontEnd/TypeSynonyms.hs 29
-    deriving(Monoid,Binary,HasSize)
+    deriving(Monoid,HasSize)
+
+instance Binary TypeSynonyms where
+    put (TypeSynonyms ts) = putMap ts
+    get = fmap TypeSynonyms getMap
hunk ./Ho/Binary.hs 5
-import Binary
+import Data.Binary
hunk ./Ho/Binary.hs 9
+import MapBinaryInstance
hunk ./Ho/Binary.hs 21
-    put_ bh (HoHeader ab ac ad) = do
-	    put_ bh ab
-	    lazyPut bh ac
-	    lazyPut bh ad
-    get bh = do
-    ab <- get bh
-    ac <- lazyGet bh
-    ad <- lazyGet bh
+    put (HoHeader ab ac ad) = do
+	    put ab
+	    put ac
+	    put ad
+    get = do
+    ab <- get
+    ac <- get
+    ad <- get
hunk ./Ho/Binary.hs 32
-    put_ bh (Ho aa ab ac ad ae af ag ah ai aj ak al am an) = do
-	    lazyPut bh aa
-	    lazyPut bh ab
-	    lazyPut bh ac
-	    lazyPut bh ad
-	    lazyPut bh ae
-	    lazyPut bh af
-	    lazyPut bh ag
-	    lazyPut bh ah
-	    lazyPut bh ai
-	    lazyPut bh aj
-	    lazyPut bh ak
-	    lazyPut bh al
-	    lazyPut bh am
-	    lazyPut bh an
-    get bh = do
-    aa <- lazyGet bh
-    ab <- lazyGet bh
-    ac <- lazyGet bh
-    ad <- lazyGet bh
-    ae <- lazyGet bh
-    af <- lazyGet bh
-    ag <- lazyGet bh
-    ah <- lazyGet bh
-    ai <- lazyGet bh
-    aj <- lazyGet bh
-    ak <- lazyGet bh
-    al <- lazyGet bh
-    am <- lazyGet bh
-    an <- lazyGet bh
+    put (Ho aa ab ac ad ae af ag ah ai aj ak al am an) = do
+	    put aa
+	    put ab
+	    put ac
+	    putMap ad
+	    putMap ae
+	    put af
+	    put ag
+	    put ah
+	    put ai
+	    put aj
+	    put ak
+	    putMap al
+	    put am
+	    put an
+    get = do
+    aa <- get
+    ab <- get
+    ac <- get
+    ad <- getMap
+    ae <- getMap
+    af <- get
+    ag <- get
+    ah <- get
+    ai <- get
+    aj <- get
+    ak <- get
+    al <- getMap
+    am <- get
+    an <- get
hunk ./Ho/Binary.hs 65
-    put_ bh (FileDep aa ab ac ad ae) = do
-        put_ bh aa
-        put_ bh ab
-        put_ bh ac
-        put_ bh ad
-        put_ bh ae
-    get bh = do
-        aa <- get bh
-        ab <- get bh
-        ac <- get bh
-        ad <- get bh
-        ae <- get bh
+    put (FileDep aa ab ac ad ae) = do
+        put aa
+        put ab
+        put ac
+        put ad
+        put ae
+    get = do
+        aa <- get
+        ab <- get
+        ac <- get
+        ad <- get
+        ae <- get
hunk ./Ho/Build.hs 26
+import Data.Binary
+import qualified Data.ByteString.Lazy as L
+import Codec.Compression.GZip
hunk ./Ho/Build.hs 31
-import Binary
hunk ./Ho/Build.hs 154
-    bh <- openBinIO fh
-    x <- get bh
+    lbs <- L.hGetContents fh
+    let (x,hh,ho,m2) = decode (decompress lbs)
hunk ./Ho/Build.hs 157
-    hh <- lazyGet bh
hunk ./Ho/Build.hs 159
-        ho <- lazyGet bh
-        x <- get bh
-        if x /= magic2 then (putErrLn $ "Bad ho file:" <+> fn)  >>  return Nothing else do
+        if m2 /= magic2 then (putErrLn $ "Bad ho file:" <+> fn)  >>  return Nothing else do
hunk ./Ho/Build.hs 179
-    bh <- openBinIO fh
-    x <- get bh
-    when (x /= magic) (putErrDie $ "Bad ho file magic1:" <+> fn)
-    hh <- lazyGet bh
-    ho <- lazyGet bh
-    x <- get bh
-    when (x /= magic2) (putErrDie $ "Bad ho file magic2:" <+> fn)
-    --hClose fh
+    c <- L.hGetContents fh
+    let (m1,hh,ho,m2) = decode (decompress c)
+    when (m1 /= magic) (putErrDie $ "Bad ho file magic1:" <+> fn)
+    when (m2 /= magic2) (putErrDie $ "Bad ho file magic2:" <+> fn)
hunk ./Ho/Build.hs 274
-            bh <- openBinIO fh
-            put_ bh magic
-            lazyPut bh header
-            lazyPut bh (mapHoBodies eraseE ho { hoUsedIds = mempty, hoModules = mempty })
-            put_ bh magic2
+            let theho =  mapHoBodies eraseE ho { hoUsedIds = mempty, hoModules = mempty }
+            L.hPut fh (compress $ encode (magic,header,theho,magic2))
hunk ./Ho/Type.hs 8
-import Binary
+import Data.Binary
hunk ./Info/Binary.hs 7
-import Binary
+import Data.Binary
hunk ./Info/Binary.hs 38
-putDyn :: BinHandle -> (Atom,Dynamic,Binable) -> IO ()
-putDyn h (ps,d,Binable (_::a)) = do
-    put_ h ps
-    put_ h (fromDyn d (error (show d)) :: a)
+putDyn :: (Atom,Dynamic,Binable) -> Put
+putDyn (ps,d,Binable (_::a)) = do
+    put ps
+    put (fromDyn d (error (show d)) :: a)
hunk ./Info/Binary.hs 48
-getDyn h = do
-    (ps::Atom) <- get h
+getDyn = do
+    (ps::Atom) <- get
hunk ./Info/Binary.hs 52
-            x <- get h :: IO a
+            x <- get :: Get a
hunk ./Info/Binary.hs 57
-    put_ bh (Properties (EnumBitSet props)) = put_ bh (BS.toWord props)
-    get bh = get bh >>= return . Properties . EnumBitSet . BS.fromWord
+    put (Properties (EnumBitSet props)) = put (BS.toWord props)
+    get = get >>= return . Properties . EnumBitSet . BS.fromWord
hunk ./Info/Binary.hs 62
-    put_ h nfo = putInfo h nfo
-    get h = Info.Binary.getInfo h
+    put nfo = putInfo nfo
+    get = Info.Binary.getInfo
hunk ./Info/Binary.hs 66
-putInfo h (Info ds) = do
+putInfo :: Info.Info.Info -> Put
+putInfo (Info ds) = do
hunk ./Info/Binary.hs 73
-    put_ h (length ds')
-    mapM_ (putDyn h) ds'
+    put (length ds')
+    mapM_ putDyn ds'
hunk ./Info/Binary.hs 76
-getInfo h = do
-    (n::Int) <- get h
-    xs <- replicateM n (getDyn h)
+getInfo :: Get Info.Info.Info
+getInfo = do
+    (n::Int) <- get
+    xs <- replicateM n getDyn
hunk ./Info/Binary.hs-boot 4
-import Binary
+import Data.Binary
hunk ./Info/Binary.hs-boot 6
-putInfo :: Binary.BinHandle -> Info.Info.Info -> IO ()
-getInfo :: Binary.BinHandle -> IO Info.Info.Info
+putInfo :: Info.Info.Info -> Put
+getInfo :: Get Info.Info.Info
hunk ./MapBinaryInstance.hs 1
-module MapBinaryInstance() where
+module MapBinaryInstance where
hunk ./MapBinaryInstance.hs 4
-import Binary
---import Data.FiniteMap
+import Data.Binary
hunk ./MapBinaryInstance.hs 9
-instance (Ord a,Binary a, Binary b) => Binary (Map a b) where
-    put_ bh x = do
-        put_ bh (Map.size x)
-        mapM_ (put_ bh) (Map.toList x)
-    get bh = do
-        (sz::Int) <- get bh
-        ls <- replicateM sz (get bh)
+putMap :: (Binary k,Ord k,Binary v) => Map.Map k v -> Put
+putMap x = do
+        put (Map.size x)
+        mapM_ put (Map.toList x)
+getMap :: (Binary k,Ord k,Binary v) => Get (Map.Map k v)
+getMap = do
+        (sz::Int) <- get
+        ls <- replicateM sz get
hunk ./MapBinaryInstance.hs 18
-        --get bh >>= return . Map.fromList
hunk ./MapBinaryInstance.hs 19
-{-
-instance (Ord a,Binary a, Binary b) => Binary (FiniteMap a b) where
-   put_ bh x = put_ bh (fmToList x)
-   get bh = get bh >>= return . listToFM
--}
hunk ./MapBinaryInstance.hs 20
-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)
+putSet :: (Binary a,Ord a) => Set.Set a -> Put
+putSet x = do
+        put (Set.size x)
+        mapM_ put (Set.toList x)
+
+getSet :: (Binary a,Ord a) => Get (Set.Set a)
+getSet = do
+        (sz::Int) <- get
+        ls <- replicateM sz get
hunk ./MapBinaryInstance.hs 30
-        --get bh >>= return . Map.fromList
hunk ./Name/Binary.hs 6
-import Binary
+import Data.Binary
hunk ./Name/Binary.hs 12
-    put_ bh ids = do
-        putNList bh [ id | id <- idSetToList ids, isNothing (fromId id)]
-        putNList bh [ n | id <- idSetToList ids, n <- fromId id]
-    get bh = do
-        (idl:: [Id])   <- getNList bh
-        (ndl:: [Name]) <- getNList bh
+    put ids = do
+        put [ id | id <- idSetToList ids, isNothing (fromId id)]
+        put [ n | id <- idSetToList ids, n <- fromId id]
+    get = do
+        (idl:: [Id])   <- get
+        (ndl:: [Name]) <- get
hunk ./Name/Binary.hs 22
-    put_ bh ids = do
-        putNList bh [ x | x@(id,_) <- idMapToList ids, isNothing (fromId id)]
-        putNList bh [ (n,v) | (id,v) <- idMapToList ids, n <- fromId id]
-    get bh = do
-        idl <- getNList bh
-        ndl <- getNList bh
+    put ids = do
+        put [ x | x@(id,_) <- idMapToList ids, isNothing (fromId id)]
+        put [ (n,v) | (id,v) <- idMapToList ids, n <- fromId id]
+    get = do
+        idl <- get
+        ndl <- get
hunk ./Name/Name.hs 29
-import Binary
+import Data.Binary
hunk ./Number.hs 4
-import Binary
+import Data.Binary
hunk ./PackedString.hs 16
+
hunk ./PackedString.hs 32
-        lengthPS,
-        utfLengthPS,
+--        lengthPS,
+--        utfLengthPS,
hunk ./PackedString.hs 41
-        foldrPS,
+--        foldrPS,
hunk ./PackedString.hs 44
-        foldlPS,
-        headPS,
+--        foldlPS,
+--        headPS,
hunk ./PackedString.hs 48
-{-
-	headPS,      -- :: PackedString -> Char
-	tailPS,      -- :: PackedString -> PackedString
-	lengthPS,    -- :: PackedString -> Int
-	indexPS,     -- :: PackedString -> Int -> Char
-	mapPS,       -- :: (Char -> Char) -> PackedString -> PackedString
-	filterPS,    -- :: (Char -> Bool) -> PackedString -> PackedString
-	reversePS,   -- :: PackedString -> PackedString
-	elemPS,      -- :: Char -> PackedString -> Bool
-	substrPS,    -- :: PackedString -> Int -> Int -> PackedString
-	takePS,      -- :: Int -> PackedString -> PackedString
-	dropPS,      -- :: Int -> PackedString -> PackedString
-	splitAtPS,   -- :: Int -> PackedString -> (PackedString, PackedString)
-
-	foldlPS,     -- :: (a -> Char -> a) -> a -> PackedString -> a
-	foldrPS,     -- :: (Char -> a -> a) -> a -> PackedString -> a
-	takeWhilePS, -- :: (Char -> Bool) -> PackedString -> PackedString
-	dropWhilePS, -- :: (Char -> Bool) -> PackedString -> PackedString
-	spanPS,      -- :: (Char -> Bool) -> PackedString -> (PackedString, PackedString)
-	breakPS,     -- :: (Char -> Bool) -> PackedString -> (PackedString, PackedString)
-	linesPS,     -- :: PackedString -> [PackedString]
-	unlinesPS,   -- :: [PackedString] -> PackedString
-	wordsPS,     -- :: PackedString -> [PackedString]
-	unwordsPS,   -- :: [PackedString] -> PackedString
-	splitPS,     -- :: Char -> PackedString -> [PackedString]
-	splitWithPS, -- :: (Char -> Bool) -> PackedString -> [PackedString]
-
-	-- * I\/O with @PackedString@s
-	hPutPS,      -- :: Handle -> PackedString -> IO ()
-	hGetPS,      -- :: Handle -> Int -> IO PackedString
-    -}
hunk ./PackedString.hs 55
+import Data.Int
+import Data.Binary
+import qualified Data.ByteString as BS
hunk ./PackedString.hs 76
-newtype PackedString = PS (UArray Int Word8)
-    deriving(Typeable)
-
+newtype PackedString = PS BS.ByteString
+    deriving(Typeable,Binary)
hunk ./PackedString.hs 83
-    {-
-   (PS (UArray _ (I# e) ba)) == (PS (UArray _ (I# e') ba'))
-    | e ==# e' = c_memcmp ba ba' (e +# 1#) ==# 0#
-    | otherwise = False
-    -}
hunk ./PackedString.hs 86
-    {-
-    compare (PS (UArray _ (I# e) ba)) (PS (UArray _ (I# e') ba'))
-        | e <# e' =  f LT (c_memcmp ba ba' (e +# 1#))
-        | e ># e' =  f GT (c_memcmp ba ba' (e' +# 1#))
-        | e ==# e' = f EQ (c_memcmp ba ba' (e +# 1#))
-            where
-            f eq 0# = eq
-            f _ x | x ># 0# = GT
-            f _ _ = LT
-     -}
hunk ./PackedString.hs 89
---instance Read PackedString: ToDo
hunk ./PackedString.hs 90
--- this is effectivly pure.
---foreign import ccall unsafe "memcmp" c_memcmp :: ByteArray# -> ByteArray# -> Int# -> Int#
hunk ./PackedString.hs 96
-nilPS = PS (array (0,-1) [])
+nilPS = PS BS.empty
hunk ./PackedString.hs 105
-packString str = PS $ listArray (0, I# (utfCount str -# 1#)) (toUTF str)
+packString str = PS $ (BS.pack $ toUTF str)
hunk ./PackedString.hs 113
-unpackPS (PS (UArray _ (I# e) ba)) = unpackFoldrUtf8# (ba) (e +# 1#) f [] where
-    f ch r = C# ch : r
+unpackPS (PS bs) = fromUTF (BS.unpack bs)
+--unpackPS (PS (UArray _ (I# e) ba)) = unpackFoldrUtf8# (ba) (e +# 1#) f [] where
+--    f ch r = C# ch : r
hunk ./PackedString.hs 118
-showsPS  (PS (UArray _ (I# e) ba)) xs = unpackFoldrUtf8# (ba) (e +# 1#) f xs where
-    f ch r = C# ch : r
+showsPS ps = (unpackPS ps ++)
+--showsPS  (PS (UArray _ (I# e) ba)) xs = unpackFoldrUtf8# (ba) (e +# 1#) f xs where
+--    f ch r = C# ch : r
hunk ./PackedString.hs 124
-toUTF8 (PS ba) = elems ba
+toUTF8 (PS ba) = BS.unpack ba
hunk ./PackedString.hs 126
-lengthPS :: PackedString -> Int
-lengthPS (PS (UArray _ (I# e) ba)) =  unpackFoldlUtf8#  (\x _ -> x + 1) 0 ba (e +# 1#)
+--lengthPS :: PackedString -> Int
+--lengthPS (PS (UArray _ (I# e) ba)) =  unpackFoldlUtf8#  (\x _ -> x + 1) 0 ba (e +# 1#)
hunk ./PackedString.hs 129
-utfLengthPS :: PackedString -> Int
-utfLengthPS (PS (UArray _ e _)) = e + 1
+--utfLengthPS :: PackedString -> Int
+--utfLengthPS (PS (UArray _ e _)) = e + 1
hunk ./PackedString.hs 132
-headPS :: PackedString -> Char
-headPS ps = case unpackPS ps of
-    (x:_) -> x
-    [] -> error "headPS: empty PackedString"
+--headPS :: PackedString -> Char
+--headPS ps = case unpackPS ps of
+--    (x:_) -> x
+--    [] -> error "headPS: empty PackedString"
hunk ./PackedString.hs 160
-nullPS (PS ps) = rangeSize (bounds ps) == 0
+nullPS (PS ps) = BS.null ps
hunk ./PackedString.hs 164
-appendPS xs ys
-  | nullPS xs = ys
-  | nullPS ys = xs
-  | otherwise  = concatPS [xs,ys]
+appendPS (PS xs) (PS ys) = PS (BS.append xs ys)
hunk ./PackedString.hs 166
--- | The 'mapPS' function applies a function to each character in the string.
---mapPS :: (Char -> Char) -> PackedString -> PackedString
---mapPS f (PS ps) = PS (amap f ps)
hunk ./PackedString.hs 173
-foldlPS :: (a -> Char -> a) -> a -> PackedString -> a
-foldlPS f b (PS (UArray _ (I# e) ba)) = unpackFoldlUtf8# (\x y -> f x (C# y)) b ba (e +# 1#)
+--foldlPS :: (a -> Char -> a) -> a -> PackedString -> a
+--foldlPS f b (PS (UArray _ (I# e) ba)) = unpackFoldlUtf8# (\x y -> f x (C# y)) b ba (e +# 1#)
hunk ./PackedString.hs 177
-foldrPS :: (Char -> a -> a) -> a -> PackedString -> a
-foldrPS f b (PS (UArray _ (I# e) ba)) = unpackFoldrUtf8# ba (e +# 1#) (\x y -> f (C# x)  y) b
+--foldrPS :: (Char -> a -> a) -> a -> PackedString -> a
+--foldrPS f b (PS (UArray _ (I# e) ba)) = unpackFoldrUtf8# ba (e +# 1#) (\x y -> f (C# x)  y) b
hunk ./PackedString.hs 181
-{-
hunk ./PackedString.hs 182
-hashPS (PS arr) = f 5381 (elems arr) where
+hashPS (PS arr) = f 5381 (BS.unpack arr) where
hunk ./PackedString.hs 186
+{-
hunk ./PackedString.hs 191
--}
hunk ./PackedString.hs 197
+-}
hunk ./PackedString.hs 382
+fromUTF :: [Word8] -> String
+fromUTF xs = fromUTF' (map fromIntegral xs) where
+    fromUTF' [] = []
+    fromUTF' (all@(x:xs))
+	| x<=0x7F = (chr (x)):fromUTF' xs
+	| x<=0xBF = err
+	| x<=0xDF = twoBytes all
+	| x<=0xEF = threeBytes all
+	| otherwise   = err
+    twoBytes (x1:x2:xs) = chr  ((((x1 .&. 0x1F) `shift` 6) .|.
+			       (x2 .&. 0x3F))):fromUTF' xs
+    twoBytes _ = error "fromUTF: illegal two byte sequence"
+
+    threeBytes (x1:x2:x3:xs) = chr ((((x1 .&. 0x0F) `shift` 12) .|.
+				    ((x2 .&. 0x3F) `shift` 6) .|.
+				    (x3 .&. 0x3F))):fromUTF' xs
+    threeBytes _ = error "fromUTF: illegal three byte sequence"
+
+    err = error "fromUTF: illegal UTF-8 character"
hunk ./SelfTest.hs 12
-import Binary
+import Data.Binary
hunk ./SelfTest.hs 73
-        prop_pslen xs = lengthPS (packString xs) == length (xs::String)
+--        prop_pslen xs = lengthPS (packString xs) == length (xs::String)
hunk ./SelfTest.hs 78
-    quickCheck prop_pslen
+--    quickCheck prop_pslen
hunk ./SelfTest.hs 165
-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
hunk ./SelfTest.hs 171
-    putFile fn test
-    x <- getFile fn
+    encodeFile fn test
+    x <- decodeFile fn
hunk ./SelfTest.hs 180
-    putFile fn nf
-    x@(nfo,_,_) <- getFile fn
+    encodeFile fn nf
+    x@(nfo,_,_) <- decodeFile fn