Properly parse Code attribute.
[hs-java.git] / Data / BinaryState.hs
index c2ab55d89cc119c02d672421fdd7e656d76d82cd..782e0c918f4bc635ed0489c1036cc2e1311fd3b1 100644 (file)
@@ -36,6 +36,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)