Skip to content

Commit 6416d36

Browse files
authored
Merge pull request #7 from GregorySchwartz/master
Add decompressAll
2 parents 3f63438 + 8ddd8ec commit 6416d36

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Streaming/Zip.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Streaming.Zip (
44
-- * Streams
55
decompress
66
, decompress'
7+
, decompressAll
78
, compress
89
, gunzip
910
, gunzip'
@@ -83,6 +84,14 @@ decompress' wbits p0 = go p0 =<< liftIO (Z.initInflate wbits)
8384
else return $ Left (chunk leftover >> p')
8485
{-# INLINABLE decompress' #-}
8586

87+
-- | Keep decompressing a compressed bytestream until exhausted.
88+
decompressAll :: MonadIO m => Z.WindowBits -> ByteString m r -> ByteString m r
89+
decompressAll w bs = decompress' w bs >>= go
90+
where
91+
go (Left bs) = decompress' w bs >>= go
92+
go (Right r) = return r
93+
{-# INLINABLE decompressAll #-}
94+
8695
-- | Compress a byte stream.
8796
--
8897
-- See the "Codec.Compression.Zlib" module for details about

0 commit comments

Comments
 (0)