From b180ac61a5f6fb06a43da37a82428e1f74ea75d6 Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 6 Aug 2009 11:19:04 +0000 Subject: merge some changes from the latest version of Data.Binary. Makes the binary decoding faster --- src/Data/Binary/Put.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Data/Binary/Put.hs') 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 -- cgit v1.2.3