module Bio.Util.Zlib ( decompressGzip ) where
import Prelude
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Internal as L ( ByteString(..) )
import qualified Codec.Compression.Zlib.Internal as Z
decompressGzip :: L.ByteString -> L.ByteString
decompressGzip s = case L.uncons s of
Just (31, s') -> case L.uncons s' of
Just (139,_) -> Z.foldDecompressStreamWithInput L.Chunk decompressGzip (const s)
(Z.decompressST Z.gzipOrZlibFormat Z.defaultDecompressParams) s
_ -> s
_ -> s