Update docs.
[hs-java.git] / Data / BinaryState.hs
index c2ab55d89cc119c02d672421fdd7e656d76d82cd..fc7fa1d658e8a73f28a6fa5390f0671cb986f6fa 100644 (file)
@@ -7,7 +7,6 @@ import qualified Data.Binary as Binary
 import qualified Data.Binary.Put as Put
 import qualified Data.Binary.Get as Get
 import qualified Data.ByteString.Lazy as B
-import Foreign.Storable
 import Data.Word
 import Data.Int
 
@@ -36,6 +35,11 @@ encodeS s a = Put.runPut $ State.evalStateT (put a) s
 decodeS :: (BinaryState s a) => s -> B.ByteString -> a
 decodeS s str = Get.runGet (State.evalStateT get s) str
 
+decodeWith :: GetState s a -> s -> B.ByteString -> a
+decodeWith getter s str =
+  let (x,_,_) = Get.runGetState (State.evalStateT getter s) str 0
+  in  x
+
 encodeFile :: BinaryState s a => FilePath -> s -> a -> IO ()
 encodeFile f s v = B.writeFile f (encodeS s v)