[fix Binary instance for Integer
John Meacham <john@repetae.net>**20061222025623] hunk ./Binary.hs 331
-                          _ -> do x  <- get bh
+                          1 -> do x  <- get bh
hunk ./Binary.hs 363
-            _ -> do
+            1 -> do
hunk ./Binary.hs 373
-                             _ -> do b <- get bh ; return (Right b)
+                             1 -> do b <- get bh ; return (Right b)
hunk ./Binary.hs 395
-instance Binary Integer where
-    put_ bh (S# i#) = do putByte bh 0; put_ bh (I# i#)
-    put_ bh (J# s# a#) = do
- 	p <- putByte bh 1;
-	put_ bh (I# s#)
-	let sz# = sizeofByteArray# a#  -- in *bytes*
-	put_ bh (I# sz#)  -- in *bytes*
-	putByteArray bh a# sz#
+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
hunk ./Binary.hs 406
+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)
hunk ./Binary.hs 414
-	b <- getByte bh
-	case b of
-	  0 -> do (I# i#) <- get bh
-		  return (S# i#)
-	  _ -> do (I# s#) <- get bh
-		  sz <- get bh
-		  (BA a#) <- getByteArray bh sz
-		  return (J# s# a#)
+        b <- getByte bh
+        is <- getNList bh
+        case b of
+            1 -> return $ negate $ fromInts is
+            0 -> return $ fromInts is