summaryrefslogtreecommitdiff
path: root/src/Data/Binary/Put.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-08-06 11:19:04 +0000
committerkrasimir <krasimir@chalmers.se>2009-08-06 11:19:04 +0000
commitb180ac61a5f6fb06a43da37a82428e1f74ea75d6 (patch)
treee4a12b5462718ee11d5659062ac7e1e603f98b03 /src/Data/Binary/Put.hs
parent3473f0d274fdeaa2a29bfeebacc63a6f5aaaaf9d (diff)
merge some changes from the latest version of Data.Binary. Makes the binary decoding faster
Diffstat (limited to 'src/Data/Binary/Put.hs')
-rw-r--r--src/Data/Binary/Put.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Data/Binary/Put.hs b/src/Data/Binary/Put.hs
index 353bfb7b1..a1f78dfba 100644
--- a/src/Data/Binary/Put.hs
+++ b/src/Data/Binary/Put.hs
@@ -19,6 +19,9 @@ module Data.Binary.Put (
Put
, PutM(..)
, runPut
+ , runPutM
+ , putBuilder
+ , execPut
-- * Flushing the implicit parse state
, flush
@@ -107,11 +110,25 @@ tell :: Builder -> Put
tell b = Put $ PairS () b
{-# INLINE tell #-}
+putBuilder :: Builder -> Put
+putBuilder = tell
+{-# INLINE putBuilder #-}
+
+-- | Run the 'Put' monad
+execPut :: PutM a -> Builder
+execPut = sndS . unPut
+{-# INLINE execPut #-}
+
-- | Run the 'Put' monad with a serialiser
runPut :: Put -> L.ByteString
runPut = toLazyByteString . sndS . unPut
{-# INLINE runPut #-}
+-- | Run the 'Put' monad with a serialiser and get its result
+runPutM :: PutM a -> (a, L.ByteString)
+runPutM (Put (PairS f s)) = (f, toLazyByteString s)
+{-# INLINE runPutM #-}
+
------------------------------------------------------------------------
-- | Pop the ByteString we have constructed so far, if any, yielding a