Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipes-binary.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: pipes-binary
version: 0.4.0
version: 0.4.1
license: BSD3
license-file: LICENSE
copyright: Copyright (c) Renzo Carbonara 2013-2014
Expand Down
14 changes: 14 additions & 0 deletions src/Pipes/Binary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Pipes.Binary (
-- ** Explicit 'Get'
, decodeGet
, decodeGetL
, getMany

-- * Types
, DecodingError(..)
Expand Down Expand Up @@ -202,6 +203,19 @@ decodeGetL m = S.StateT (go id (Get.runGetIncremental m))
Right (bs, p1) -> go (diffP . (yield bs >>)) (k (Just bs)) p1
{-# INLINABLE decodeGetL #-}

-- |Produce values from a ByteString, given an explicit Get monad
getMany
:: (Monad m) => Get a -> Producer ByteString m r -> Producer a m DecodingError
getMany getA = go
where go p = do
(x,p') <- lift $ S.runStateT (decodeGet getA) p
case x of
Left err -> return err
Right a -> do
yield a
go p'
{-# INLINABLE getMany #-}

--------------------------------------------------------------------------------

-- | A 'Get' decoding error, as provided by 'Get.Fail'.
Expand Down