diff options
Diffstat (limited to 'src/Data/Binary/Put.hs')
| -rw-r--r-- | src/Data/Binary/Put.hs | 17 |
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 |
