>i      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh(c) 2006-2015 Duncan Coutts BSD-styleduncan@community.haskell.orgNone+0AThe strategy parameter is used to tune the compression algorithm.The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately.The  parameter specifies how much memory should be allocated for the internal compression state. It is a tradoff between memory usage, compression ratio and compression speed. Using more memory allows faster compression and a better compression ratio.?The total amount of memory used for compression depends on the   and the ,. For decompression it depends only on the  (. The totals are given by the functions: qcompressTotal windowBits memLevel = 4 * 2^windowBits + 512 * 2^memLevel decompressTotal windowBits = 2^windowBits.For example, for compression with the default windowBits = 15 and  memLevel = 8 uses 256KbT. So for example a network server with 100 concurrent compressed streams would use 25Mbt. The memory per stream can be halved (at the cost of somewhat degraded and slower compressionby) by reducing the  windowBits and memLevel by one.-Decompression takes less memory, the default windowBits = 15 corresponds to just 32Kb. This specifies the size of the compression window. Larger values of this parameter result in better compression at the expense of higher memory usage.}The compression window size is the value of the the window bits raised to the power 2. The window bits must be in the range 8..15s which corresponds to compression window sizes of 256b to 32Kb. The default is 15 which is also the maximum size.DThe total amount of memory used depends on the window bits and the  . See the  for the details. The compression level parameter controls the amount of compression. This is a trade-off between the amount of compression and the time required to do the compression.The compression methodNThe format used for compression or decompression. There are three variations.iSNo progress was possible or there was not enough room in the output buffer when j is used. Note that  BuferError is not fatal, and kJ can be called again with more input and more output space to continue.lA hash of a custom compression dictionary. These hashes are used by zlib as dictionary identifiers. (The particular hash function used is Adler32.)mUpdate a running l. You can generate a l from one or more ns by starting from o, e.g. AdictionaryHash zeroDictionaryHash :: ByteString -> DictionaryHashor Jfoldl' dictionaryHash zeroDictionaryHash :: [ByteString] -> DictionaryHashoA zero l" to use as the initial value with m.The gzip format uses a header with a checksum and some optional meta-data about the compressed file. It is intended primarily for compressing individual files but is also sometimes used for network protocols such as HTTP. The format is described in detail in RFC #1952 #http://www.ietf.org/rfc/rfc1952.txtThe zlib format uses a minimal header with a checksum but no other meta-data. It is especially designed for use in network protocols. The format is described in detail in RFC #1950 #http://www.ietf.org/rfc/rfc1950.txtThe 'raw' format is just the compressed data stream without any additional header, meta-data or data-integrity checksum. The format is described in detail in RFC #1951 #http://www.ietf.org/rfc/rfc1951.txtThis is not a format as such. It enabled zlib or gzip decoding with automatic header detection. This only makes sense for decompression.'Deflate' is the only method supported in this version of zlib. Indeed it is likely to be the only method that ever will be supported.eThe default compression level is 6 (that is, biased towards higher compression at expense of speed)."No compression, just a block copy. 1The fastest compression method (less compression)!2The slowest compression method (best compression)."-A specific compression level between 0 and 9.# The default  & is 15 which is also the maximum size.$CA specific compression window size, specified in bits in the range 8..15%)The default memory level. (Equivalent to ( 8)&TUse minimum memory. This is slow and reduces the compression ratio. (Equivalent to ( 1)'BUse maximum memory for optimal compression speed. (Equivalent to ( 9)(A specific level in the range 1..9)6Use this default compression strategy for normal data.*pUse the filtered compression strategy for data produced by a filter (or predictor). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of this strategy is to force more Huffman coding and less string matching; it is somewhat intermediate between defaultCompressionStrategy and huffmanOnlyCompressionStrategy.+\Use the Huffman-only compression strategy to force Huffman encoding only (no string match).p#This never needs to be used as the stream's resources will be released automatically when no longer needed, however this can be used to release them early. Only use this when you can guarantee that the stream will no longer be needed, for example if an error occurs or if the stream ends.qr sjtuvwxyiz{|}~lkmo !"#$%&'()*+pW sjtuvwxyiz{|}~lkmo !"#$%&'()*+pgqr   svutjw~}|{ziyxlkmo !"#$%&'()*+p(c) 2006-2015 Duncan Coutts BSD-styleduncan@community.haskell.org Trustworthy+HM, The unfolding of the compression process, where you provide a sequence of uncompressed data chunks as input and receive a sequence of compressed data chunks as output. The process is incremental, in that the demand for input and provision of output are interleaved.35The possible error cases when decompressing a stream. This can be )n to give a human readable error message.4@If the compressed data stream is corrupted in any way then you will get this error, for example if the input data just isn't a compressed zlib data stream. In particular if the data checksum turns out to be wrong then you will get all the decompressed data but this error at the end, instead of the normal sucessful  StreamEnd.5HIf the stream requires a dictionary and you provide one with the wrong DictionaryHash then you will get this error.6;It is possible to do zlib compression with a custom dictionary. This allows slightly higher compression ratios for short files. However such compressed streams require the same dictionary when decompressing. This error is for when we encounter a compressed stream that needs a dictionary, and it's not provided.7fThe compressed data stream ended prematurely. This may happen if the input data stream was truncated.8The unfolding of the decompression process, where you provide a sequence of compressed data chunks as input and receive a sequence of uncompressed data chunks as output. The process is incremental, in that the demand for input and provision of output are interleaved.MTo indicate the end of the input supply an empty input chunk. Note that for  gzipFormat with the default G True[ you will have to do this, as the decompressor will look for any following members. With G False= the decompressor knows when the data ends and will produce ;O without you having to supply an empty chunk to indicate the end of the input.9 An error code;!Includes any trailing unconsumed input data.B@The full set of parameters for decompression. The defaults are R.The E is the size of the first output buffer, containing the uncompressed data. If you know an exact or approximate upper bound on the size of the decompressed data then setting this parameter can save memory. The default decompression output buffer size is 32ky. If your extimate is wrong it does not matter too much, the default buffer size will be used for the remaining chunks.(One particular use case for setting the EW is if you know the exact size of the decompressed data and want to produce a strict 9. The compression and deccompression functions use lazy s but if you set the E) correctly then you can generate a lazy = with exactly one chunk, which can be converted to a strict  in O(1) time using   .  .H>The full set of parameters for compression. The defaults are Q.The O is the size of the first output buffer containing the compressed data. If you know an approximate upper bound on the size of the compressed data then setting this parameter can save memory. The default compression output buffer size is 16ky. If your extimate is wrong it does not matter too much, the default buffer size will be used for the remaining chunks.QPThe default set of parameters for compression. This is typically used with the  compressWith. function with specific parameters overridden.RRThe default set of parameters for decompression. This is typically used with the  compressWith. function with specific parameters overridden.The default chunk sizes for the output of compression and decompression are 16k and 32k respectively (less a small accounting overhead).The default chunk sizes for the output of compression and decompression are 16k and 32k respectively (less a small accounting overhead).SA fold over the 8 in the given monad.iOne way to look at this is that it runs the stream, using callback functions for the four stream events.T A variant on UZ that is pure rather than operating in a monad and where the input is provided by a lazy t. So we only have to deal with the output, end and error parts, making it like a foldr on a list of output chunks. For example: 5toChunks = foldDecompressStreamWithInput (:) [] throwUA fold over the , in the given monad.jOne way to look at this is that it runs the stream, using callback functions for the three stream events.V A variant on UZ that is pure rather than operating in a monad and where the input is provided by a lazy r. So we only have to deal with the output and end parts, making it just like a foldr on a list of output chunks. For example: -toChunks = foldCompressStreamWithInput (:) []W*Compress a data stream provided as a lazy .There are no expected error conditions. All input data streams are valid. It is possible for unexpected errors to occur, such as running out of memory, or finding the wrong version of the zlib C library, these are thrown as exceptions.XIncremental compression in the  monad. Using " makes it possible to write pure lazy7 functions while making use of incremental compression.YIncremental compression in the  monad.Z,Decompress a data stream provided as a lazy .It will throw an exception if any error is encountered in the input data. If you need more control over error handling then use one the incremental versions, [ or \.[!Incremental decompression in the  monad. Using " makes it possible to write pure lazy9 functions while making use of incremental decompression.\!Incremental decompression in the  monad.@,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]WZ,1.-2/0XYUV8@=;9A>?<:37654[\STHIJKLMNOPQBCDEFGR   !" #$%&'()*+ ,1.-2/0376548 @=;9A>?<:BCDEFGHIJKLMNOPQRSTUVWXYZ[\(c) 2006-2014 Duncan Coutts BSD-styleduncan@community.haskell.org Safe-Inferred]^_`8  !"#$%&'()*+BCDEFGHIJKLMNOPQR]^_`8_]`^HIJKLMNOPQBCDEFGR   !" #$%&'()*+]^_`(c) 2006-2014 Duncan Coutts BSD-styleduncan@community.haskell.org Safe-Inferreda/Decompress a stream of data in the zlib format.zThere are a number of errors that can occur. In each case an exception will be thrown. The possible error conditions are:5if the stream does not start with a valid gzip header%if the compressed stream is corrupted)if the compressed stream ends permaturely)Note that the decompression is performed lazily). Errors in the data stream may not be detected until the end of the stream is demanded (since it is only at the end that the final checksum can be checked). If this is important to you, you must make sure to consume the whole decompressed stream before doing any IO action that depends on it.bLike aR but with the ability to specify various decompression parameters. Typical usage: ,decompressWith defaultCompressParams { ... }c/Compress a stream of data into the zlib format.This uses the default compression parameters. In partiular it uses the default compression level which favours a higher compression ratio over compression speed, though it does not use the maximum compression level.Use dB to adjust the compression level or other compression parameters.dLike cP but with the ability to specify various compression parameters. Typical usage: *compressWith defaultCompressParams { ... }0In particular you can set the compression level: FcompressWith defaultCompressParams { compressLevel = BestCompression }abcd8  !"#$%&'()*+BCDEFGHIJKLMNOPQRabcd8cadbHIJKLMNOPQBCDEFGR   !" #$%&'()*+abcd(c) 2006-2014 Duncan Coutts BSD-styleduncan@community.haskell.org Safe-Inferrede/Decompress a stream of data in the gzip format.zThere are a number of errors that can occur. In each case an exception will be thrown. The possible error conditions are:5if the stream does not start with a valid gzip header%if the compressed stream is corrupted)if the compressed stream ends permaturely)Note that the decompression is performed lazily). Errors in the data stream may not be detected until the end of the stream is demanded (since it is only at the end that the final checksum can be checked). If this is important to you, you must make sure to consume the whole decompressed stream before doing any IO action that depends on it.fLike eR but with the ability to specify various decompression parameters. Typical usage: ,decompressWith defaultCompressParams { ... }g/Compress a stream of data into the gzip format.This uses the default compression parameters. In partiular it uses the default compression level which favours a higher compression ratio over compression speed, though it does not use the maximum compression level.Use hB to adjust the compression level or other compression parameters.hLike gP but with the ability to specify various compression parameters. Typical usage: *compressWith defaultCompressParams { ... }0In particular you can set the compression level: FcompressWith defaultCompressParams { compressLevel = BestCompression }efgh8  !"#$%&'()*+BCDEFGHIJKLMNOPQRefgh8gehfHIJKLMNOPQBCDEFGR   !" #$%&'()*+efgh    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJJKLMNOOPQRSTUVWXYZ[\]^_`ab`c]d`c]d`c]defghijklmnnopqrstuvwxyz{|}~j zlib-0.6.1.0Codec.Compression.Zlib.InternalCodec.Compression.Zlib.RawCodec.Compression.ZlibCodec.Compression.GZipCodec.Compression.Zlib.StreamData.ByteString ByteStringData.ByteString.LazyconcattoChunksCompressionStrategy HuffmanOnlyFilteredDefaultStrategy MemoryLevelMaxMemoryLevelMinMemoryLevelDefaultMemoryLevel WindowBitsDefaultWindowBitsCompressionLevelBestCompression BestSpeed NoCompressionDefaultCompressionMethodDeflatedFormat GZipOrZlibRawZlibGZip gzipFormat zlibFormat rawFormatgzipOrZlibFormat deflateMethoddefaultCompression noCompression bestSpeedbestCompressioncompressionLeveldefaultWindowBits windowBitsdefaultMemoryLevelminMemoryLevelmaxMemoryLevel memoryLeveldefaultStrategyfilteredStrategyhuffmanOnlyStrategyCompressStreamCompressStreamEndCompressOutputAvailablecompressOutput compressNextCompressInputRequiredcompressSupplyInputDecompressErrorDataFormatErrorDictionaryMismatchDictionaryRequiredTruncatedInputDecompressStreamDecompressStreamErrordecompressStreamErrorDecompressStreamEnddecompressUnconsumedInputDecompressOutputAvailabledecompressOutputdecompressNextDecompressInputRequireddecompressSupplyInputDecompressParamsdecompressWindowBitsdecompressBufferSizedecompressDictionarydecompressAllMembersCompressParams compressLevelcompressMethodcompressWindowBitscompressMemoryLevelcompressStrategycompressBufferSizecompressDictionarydefaultCompressParamsdefaultDecompressParamsfoldDecompressStreamfoldDecompressStreamWithInputfoldCompressStreamfoldCompressStreamWithInputcompress compressST compressIO decompress decompressST decompressIOdecompressWith compressWith BufferErrorFinishinflateDictionaryHashdictionaryHashbytestring-0.10.4.0Data.ByteString.InternalzeroDictionaryHashfinalise StreamStateFlush FullFlush SyncFlushNoFlush ErrorCode Unexpected VersionError MemoryError DataError StreamError FileErrorNeedDictStatusError StreamEndOkStateStreamZunZDictHash c_adler32 c_zlibVersion c_deflateEnd c_deflatec_inflateSetDictionaryc_deflateSetDictionaryc_deflateInit2_c_inflateReset c_inflateEnd c_inflatec_inflateInit2_pushInputBufferinputBufferEmptypopRemainingInputBufferpushOutputBufferpopOutputBufferoutputBufferBytesAvailableoutputBufferSpaceRemainingoutputBufferFulldeflate inflateResetdeflateSetDictionaryinflateSetDictionaryreturnZthenZthenZ_failZmkState runStream unsafeLiftIOgetStreamStategetInBuf getOutBuf getOutOffset getOutAvailsetInBuf setOutBuf setOutOffset setOutAvailtoStatus failIfError fromFlushformatSupportsDictionary fromMethodfromCompressionLevelfromWindowBitsfromMemoryLevelfromCompressionStrategy withStreamPtrwithStreamState setInAvail getInAvail setInNext getInNext setOutFree getOutFree setOutNext inflateInit deflateInitinflate_deflate_checkFormatSupportedc_inflateInit2c_deflateInit2 $fMonadStream$fApplicativeStream$fFunctorStreambaseGHC.ShowshowdefaultCompressBufferSizedefaultDecompressBufferSizeData.ByteString.Lazy.InternalControl.Monad.ST.Lazy.ImpSTghc-prim GHC.TypesIO modprefixcompressStreamdecompressStream mkStateST mkStateIO runStreamST runStreamIOcompressStreamIOcompressStreamSTdecompressStreamIOdecompressStreamST$fExceptionDecompressError$fShowDecompressError