From 906232de902dda62f86bc7e8af69b278bb550e5c Mon Sep 17 00:00:00 2001 From: "Gregory W. Schwartz" Date: Fri, 30 Aug 2019 10:33:03 -0400 Subject: [PATCH 1/2] Added decompressAll. --- Streaming/Zip.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Streaming/Zip.hs b/Streaming/Zip.hs index ebfebdf..1b853bd 100644 --- a/Streaming/Zip.hs +++ b/Streaming/Zip.hs @@ -4,6 +4,7 @@ module Streaming.Zip ( -- * Streams decompress , decompress' + , decompressAll , compress , gunzip , gunzip' @@ -83,6 +84,14 @@ decompress' wbits p0 = go p0 =<< liftIO (Z.initInflate wbits) else return $ Left (chunk leftover >> p') {-# INLINABLE decompress' #-} +-- | Keep decompressing a compressed bytestream until exhaused. +decompressAll :: MonadIO m => Z.WindowBits -> ByteString m r -> ByteString m r +decompressAll w bs = decompress' w bs >>= go + where + go (Left bs) = decompress' w bs >>= go + go (Right r) = return r +{-# INLINABLE decompressAll #-} + -- | Compress a byte stream. -- -- See the "Codec.Compression.Zlib" module for details about From 8ddd8ec07c5a9050793d0875e71a41847458ce19 Mon Sep 17 00:00:00 2001 From: chessai Date: Fri, 30 Aug 2019 11:18:18 -0400 Subject: [PATCH 2/2] fix typo (exhaused -> exhausted) --- Streaming/Zip.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Streaming/Zip.hs b/Streaming/Zip.hs index 1b853bd..7523316 100644 --- a/Streaming/Zip.hs +++ b/Streaming/Zip.hs @@ -84,7 +84,7 @@ decompress' wbits p0 = go p0 =<< liftIO (Z.initInflate wbits) else return $ Left (chunk leftover >> p') {-# INLINABLE decompress' #-} --- | Keep decompressing a compressed bytestream until exhaused. +-- | Keep decompressing a compressed bytestream until exhausted. decompressAll :: MonadIO m => Z.WindowBits -> ByteString m r -> ByteString m r decompressAll w bs = decompress' w bs >>= go where