pipes-binary 0.2.0 → 0.2.1
raw patch · 4 files changed
+28/−26 lines, 4 filesdep +pipes-bytestring
Dependencies added: pipes-bytestring
Files
- NEWS +8/−1
- PEOPLE +2/−0
- pipes-binary.cabal +8/−7
- src/Pipes/Binary.hs +10/−18
NEWS view
@@ -1,3 +1,10 @@+# Version 0.2.1++* Re-export `Put` and `Binary` from the `binary` package.++* Use `isEndOfBytes` from the `pipes-bytestring` package.++ # Version 0.2.0 * API revamped in order to support `pipes-4.0.0` and `pipes-parse-2.0.0`.@@ -8,7 +15,7 @@ * Decoding functions now report the number of bytes that were consumed in order to decode a value. -* Re-export `Get`, `Put`, `Binary` and `ByteOffset` from the `binary` package.+* Re-export `Get` and `ByteOffset` from the `binary` package. # Version 0.1.0.0
PEOPLE view
@@ -5,3 +5,5 @@ Renzo Carbonara Gabriel Gonzalez Kyle Van Berendonck+Torgeir Strand Henriksen+David Luposchainsky
pipes-binary.cabal view
@@ -1,5 +1,5 @@ name: pipes-binary-version: 0.2.0+version: 0.2.1 license: BSD3 license-file: LICENSE copyright: Copyright (c) Renzo Carbonara 2013@@ -26,12 +26,13 @@ library hs-source-dirs: src- build-depends: base (==4.*)- , binary (>=0.7 && <0.8)- , bytestring (>=0.9.2.1)- , pipes (>=4.0 && <4.1)- , pipes-parse (>=2.0 && <2.1)- , transformers (>=0.2 && <0.4)+ build-depends: base (==4.*)+ , binary (>=0.7 && <0.8)+ , bytestring (>=0.9.2.1)+ , pipes (>=4.0 && <4.1)+ , pipes-parse (>=2.0 && <2.1)+ , pipes-bytestring (>=1.0.2 && <1.2)+ , transformers (>=0.2 && <0.4) exposed-modules: Pipes.Binary other-modules: Pipes.Binary.Internal ghc-options: -Wall -O2
src/Pipes/Binary.hs view
@@ -18,8 +18,9 @@ , I.DecodingError(..) -- * Exports -- $exports- , isEndOfBytes+ , module Data.Binary , module Data.Binary.Get+ , module Data.Binary.Put ) where -------------------------------------------------------------------------------@@ -31,6 +32,7 @@ import qualified Pipes.Binary.Internal as I import qualified Pipes.Lift as P import qualified Pipes.Parse as Pp+import Pipes.ByteString.Parse (isEndOfBytes) import qualified Data.Binary as Bin (get, put) import qualified Data.Binary.Put as Put (runPut) --------------------------------------------------------------------------------@@ -126,6 +128,13 @@ -- | Encodes the given 'Bin.Binary' instance and sends it downstream in -- 'BS.ByteString' chunks.+--+-- Hint: You can easily turn this 'Producer'' into a 'Pipe' that encodes+-- 'Binary' instances as they flow downstream using:+--+-- @+-- 'for' 'cat' 'encode' :: ('Monad' m, 'Binary' a) => 'Pipe' a 'B.ByteString' m r+-- @ encode :: (Monad m, Binary x) => x -> Producer' B.ByteString m () encode = \x -> encodePut (Bin.put x) {-# INLINABLE encode #-}@@ -135,20 +144,3 @@ encodePut = \put -> do BLI.foldrChunks (\e a -> respond e >> a) (return ()) (Put.runPut put) {-# INLINABLE encodePut #-}------------------------------------------------------------------------------------- XXX: this function is here until pipes-bytestring exports it---- | Checks if the underlying 'Producer' has any bytes left.--- Leading 'BS.empty' chunks are discarded.-isEndOfBytes :: Monad m => Pp.StateT (Producer B.ByteString m r) m Bool-isEndOfBytes = do- ma <- Pp.draw- case ma of- Left _ -> return True- Right a- | B.null a -> isEndOfBytes- | otherwise -> Pp.unDraw a >> return False-{-# INLINABLE isEndOfBytes #-}-{-# DEPRECATED isEndOfBytes- "Will be removed as soon as the `pipes-bytestring` library exports it" #-}