Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 6ae69e5eca788d52d1d55e0ca5834ac8 > files > 20

ghc-zlib-devel-0.5.3.1-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Codec.Compression.Zlib.Internal</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Codec-Compression-Zlib-Internal.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Codec-Compression-Zlib-Internal.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">zlib-0.5.3.1: Compression and decompression in the gzip and zlib formats</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable (H98 + FFI)</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>duncan@haskell.org</td></tr></table><p class="caption">Codec.Compression.Zlib.Internal</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Compression
</a></li><li><a href="#g:2">Decompression
</a></li><li><a href="#g:3">The compression parameter types
</a></li><li><a href="#g:4">Low-level API to get explicit error reports
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Pure stream based interface to lower level zlib wrapper
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:compress">compress</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:CompressParams">CompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:CompressParams">CompressParams</a>  = <a href="#v:CompressParams">CompressParams</a> {<ul class="subs"><li><a href="#v:compressLevel">compressLevel</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li><a href="#v:compressMethod">compressMethod</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:Method">Method</a></li><li><a href="#v:compressWindowBits">compressWindowBits</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></li><li><a href="#v:compressMemoryLevel">compressMemoryLevel</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></li><li><a href="#v:compressStrategy">compressStrategy</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a></li><li><a href="#v:compressBufferSize">compressBufferSize</a> :: !<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li></ul>}</li><li class="src short"><a href="#v:defaultCompressParams">defaultCompressParams</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressParams">CompressParams</a></li><li class="src short"><a href="#v:decompress">decompress</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:DecompressParams">DecompressParams</a>  = <a href="#v:DecompressParams">DecompressParams</a> {<ul class="subs"><li><a href="#v:decompressWindowBits">decompressWindowBits</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></li><li><a href="#v:decompressBufferSize">decompressBufferSize</a> :: !<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li></ul>}</li><li class="src short"><a href="#v:defaultDecompressParams">defaultDecompressParams</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:Format">Format</a> <ul class="subs"><li>= <a href="#v:GZip">GZip</a>  </li><li>| <a href="#v:Zlib">Zlib</a>  </li><li>| <a href="#v:Raw">Raw</a>  </li><li>| <a href="#v:GZipOrZlib">GZipOrZlib</a>  </li></ul></li><li class="src short"><a href="#v:gzipFormat">gzipFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a></li><li class="src short"><a href="#v:zlibFormat">zlibFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a></li><li class="src short"><a href="#v:rawFormat">rawFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a></li><li class="src short"><a href="#v:gzipOrZlibFormat">gzipOrZlibFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:CompressionLevel">CompressionLevel</a> <ul class="subs"><li>= <a href="#v:DefaultCompression">DefaultCompression</a>  </li><li>| <a href="#v:NoCompression">NoCompression</a>  </li><li>| <a href="#v:BestSpeed">BestSpeed</a>  </li><li>| <a href="#v:BestCompression">BestCompression</a>  </li><li>| <a href="#v:CompressionLevel">CompressionLevel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>  </li></ul></li><li class="src short"><a href="#v:defaultCompression">defaultCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li class="src short"><a href="#v:noCompression">noCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li class="src short"><a href="#v:bestSpeed">bestSpeed</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li class="src short"><a href="#v:bestCompression">bestCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li class="src short"><a href="#v:compressionLevel">compressionLevel</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:Method">Method</a>  = <a href="#v:Deflated">Deflated</a></li><li class="src short"><a href="#v:deflateMethod">deflateMethod</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Method">Method</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:WindowBits">WindowBits</a> <ul class="subs"><li>= <a href="#v:WindowBits">WindowBits</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>  </li><li>| <a href="#v:DefaultWindowBits">DefaultWindowBits</a>  </li></ul></li><li class="src short"><a href="#v:defaultWindowBits">defaultWindowBits</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></li><li class="src short"><a href="#v:windowBits">windowBits</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:MemoryLevel">MemoryLevel</a> <ul class="subs"><li>= <a href="#v:DefaultMemoryLevel">DefaultMemoryLevel</a>  </li><li>| <a href="#v:MinMemoryLevel">MinMemoryLevel</a>  </li><li>| <a href="#v:MaxMemoryLevel">MaxMemoryLevel</a>  </li><li>| <a href="#v:MemoryLevel">MemoryLevel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>  </li></ul></li><li class="src short"><a href="#v:defaultMemoryLevel">defaultMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></li><li class="src short"><a href="#v:minMemoryLevel">minMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></li><li class="src short"><a href="#v:maxMemoryLevel">maxMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></li><li class="src short"><a href="#v:memoryLevel">memoryLevel</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:CompressionStrategy">CompressionStrategy</a> <ul class="subs"><li>= <a href="#v:DefaultStrategy">DefaultStrategy</a>  </li><li>| <a href="#v:Filtered">Filtered</a>  </li><li>| <a href="#v:HuffmanOnly">HuffmanOnly</a>  </li></ul></li><li class="src short"><a href="#v:defaultStrategy">defaultStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a></li><li class="src short"><a href="#v:filteredStrategy">filteredStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a></li><li class="src short"><a href="#v:huffmanOnlyStrategy">huffmanOnlyStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a></li><li class="src short"><a href="#v:decompressWithErrors">decompressWithErrors</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:DecompressStream">DecompressStream</a> <ul class="subs"><li>= <a href="#v:StreamEnd">StreamEnd</a>  </li><li>| <a href="#v:StreamChunk">StreamChunk</a> <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString.html#t:ByteString">ByteString</a> <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a>  </li><li>| <a href="#v:StreamError">StreamError</a> <a href="Codec-Compression-Zlib-Internal.html#t:DecompressError">DecompressError</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>  </li></ul></li><li class="src short"><span class="keyword">data</span>  <a href="#t:DecompressError">DecompressError</a> <ul class="subs"><li>= <a href="#v:TruncatedInput">TruncatedInput</a>  </li><li>| <a href="#v:DictionaryRequired">DictionaryRequired</a>  </li><li>| <a href="#v:DataError">DataError</a>  </li></ul></li><li class="src short"><a href="#v:foldDecompressStream">foldDecompressStream</a> ::  (<a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; a -&gt; a) -&gt; a -&gt; (<a href="Codec-Compression-Zlib-Internal.html#t:DecompressError">DecompressError</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a) -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a> -&gt; a</li><li class="src short"><a href="#v:fromDecompressStream">fromDecompressStream</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></li></ul></div><div id="interface"><h1 id="g:1">Compression
</h1><div class="top"><p class="src"><a name="v:compress" class="def">compress</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:CompressParams">CompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a><a href="src/Codec-Compression-Zlib-Internal.html#compress" class="link">Source</a></p><div class="doc"><p>Compress a data stream.
</p><p>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.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:CompressParams" class="def">CompressParams</a>  <a href="src/Codec-Compression-Zlib-Internal.html#CompressParams" class="link">Source</a></p><div class="doc"><p>The full set of parameters for compression. The defaults are
 <code><a href="Codec-Compression-Zlib-Internal.html#v:defaultCompressParams">defaultCompressParams</a></code>.
</p><p>The <code><a href="Codec-Compression-Zlib-Internal.html#v:compressBufferSize">compressBufferSize</a></code> 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 <code>16k</code>. If your extimate is wrong it does
 not matter too much, the default buffer size will be used for the remaining
 chunks.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:CompressParams" class="def">CompressParams</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:compressLevel" class="def">compressLevel</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:compressMethod" class="def">compressMethod</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:Method">Method</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:compressWindowBits" class="def">compressWindowBits</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:compressMemoryLevel" class="def">compressMemoryLevel</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:compressStrategy" class="def">compressStrategy</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:compressBufferSize" class="def">compressBufferSize</a> :: !<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty">&nbsp;</dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultCompressParams" class="def">defaultCompressParams</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressParams">CompressParams</a><a href="src/Codec-Compression-Zlib-Internal.html#defaultCompressParams" class="link">Source</a></p><div class="doc"><p>The default set of parameters for compression. This is typically used with
 the <code>compressWith</code> function with specific parameters overridden.
</p></div></div><h1 id="g:2">Decompression
</h1><div class="top"><p class="src"><a name="v:decompress" class="def">decompress</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a><a href="src/Codec-Compression-Zlib-Internal.html#decompress" class="link">Source</a></p><div class="doc"><p>Decompress a data stream.
</p><p>It will throw an exception if any error is encountered in the input data. If
 you need more control over error handling then use <code><a href="Codec-Compression-Zlib-Internal.html#v:decompressWithErrors">decompressWithErrors</a></code>.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:DecompressParams" class="def">DecompressParams</a>  <a href="src/Codec-Compression-Zlib-Internal.html#DecompressParams" class="link">Source</a></p><div class="doc"><p>The full set of parameters for decompression. The defaults are
 <code><a href="Codec-Compression-Zlib-Internal.html#v:defaultDecompressParams">defaultDecompressParams</a></code>.
</p><p>The <code><a href="Codec-Compression-Zlib-Internal.html#v:decompressBufferSize">decompressBufferSize</a></code> 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 <code>32k</code>. If your
 extimate is wrong it does not matter too much, the default buffer size will
 be used for the remaining chunks.
</p><p>One particular use case for setting the <code><a href="Codec-Compression-Zlib-Internal.html#v:decompressBufferSize">decompressBufferSize</a></code> is if you
 know the exact size of the decompressed data and want to produce a strict
 <code>Data.ByteString.ByteString</code>. The compression and deccompression functions
 use lazy <code>Data.ByteString.Lazy.ByteString</code>s but if you set the
 <code><a href="Codec-Compression-Zlib-Internal.html#v:decompressBufferSize">decompressBufferSize</a></code> correctly then you can generate a lazy
 <code>Data.ByteString.Lazy.ByteString</code> with exactly one chunk, which can be
 converted to a strict <code>Data.ByteString.ByteString</code> in <code>O(1)</code> time using
 <code><code>Data.ByteString.concat</code> . <code>Data.ByteString.Lazy.toChunks</code></code>.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:DecompressParams" class="def">DecompressParams</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:decompressWindowBits" class="def">decompressWindowBits</a> :: !<a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:decompressBufferSize" class="def">decompressBufferSize</a> :: !<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty">&nbsp;</dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultDecompressParams" class="def">defaultDecompressParams</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a><a href="src/Codec-Compression-Zlib-Internal.html#defaultDecompressParams" class="link">Source</a></p><div class="doc"><p>The default set of parameters for decompression. This is typically used with
 the <code>compressWith</code> function with specific parameters overridden.
</p></div></div><h1 id="g:3">The compression parameter types
</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Format" class="def">Format</a>  <a href="src/Codec-Compression-Zlib-Stream.html#Format" class="link">Source</a></p><div class="doc"><p>The format used for compression or decompression. There are three
 variations.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:GZip" class="def">GZip</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:Zlib" class="def">Zlib</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:Raw" class="def">Raw</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:GZipOrZlib" class="def">GZipOrZlib</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:Format" class="caption collapser" onclick="toggleSection('i:Format')">Instances</p><div id="section.i:Format" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:gzipFormat" class="def">gzipFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a><a href="src/Codec-Compression-Zlib-Stream.html#gzipFormat" class="link">Source</a></p><div class="doc"><p>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
 <a href="http://www.ietf.org/rfc/rfc1952.txt">http://www.ietf.org/rfc/rfc1952.txt</a>
</p></div></div><div class="top"><p class="src"><a name="v:zlibFormat" class="def">zlibFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a><a href="src/Codec-Compression-Zlib-Stream.html#zlibFormat" class="link">Source</a></p><div class="doc"><p>The 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
 <a href="http://www.ietf.org/rfc/rfc1950.txt">http://www.ietf.org/rfc/rfc1950.txt</a>
</p></div></div><div class="top"><p class="src"><a name="v:rawFormat" class="def">rawFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a><a href="src/Codec-Compression-Zlib-Stream.html#rawFormat" class="link">Source</a></p><div class="doc"><p>The '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 <a href="http://www.ietf.org/rfc/rfc1951.txt">http://www.ietf.org/rfc/rfc1951.txt</a>
</p></div></div><div class="top"><p class="src"><a name="v:gzipOrZlibFormat" class="def">gzipOrZlibFormat</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a><a href="src/Codec-Compression-Zlib-Stream.html#gzipOrZlibFormat" class="link">Source</a></p><div class="doc"><p>This is not a format as such. It enabled zlib or gzip decoding with
 automatic header detection. This only makes sense for decompression.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:CompressionLevel" class="def">CompressionLevel</a>  <a href="src/Codec-Compression-Zlib-Stream.html#CompressionLevel" class="link">Source</a></p><div class="doc"><p>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.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:DefaultCompression" class="def">DefaultCompression</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:NoCompression" class="def">NoCompression</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:BestSpeed" class="def">BestSpeed</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:BestCompression" class="def">BestCompression</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:CompressionLevel" class="def">CompressionLevel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultCompression" class="def">defaultCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#defaultCompression" class="link">Source</a></p><div class="doc"><p>The default compression level is 6 (that is, biased towards higher
 compression at expense of speed).
</p></div></div><div class="top"><p class="src"><a name="v:noCompression" class="def">noCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#noCompression" class="link">Source</a></p><div class="doc"><p>No compression, just a block copy.
</p></div></div><div class="top"><p class="src"><a name="v:bestSpeed" class="def">bestSpeed</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#bestSpeed" class="link">Source</a></p><div class="doc"><p>The fastest compression method (less compression)
</p></div></div><div class="top"><p class="src"><a name="v:bestCompression" class="def">bestCompression</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#bestCompression" class="link">Source</a></p><div class="doc"><p>The slowest compression method (best compression).
</p></div></div><div class="top"><p class="src"><a name="v:compressionLevel" class="def">compressionLevel</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:CompressionLevel">CompressionLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#compressionLevel" class="link">Source</a></p><div class="doc"><p>A specific compression level between 0 and 9.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Method" class="def">Method</a>  <a href="src/Codec-Compression-Zlib-Stream.html#Method" class="link">Source</a></p><div class="doc"><p>The compression method
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Deflated" class="def">Deflated</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:deflateMethod" class="def">deflateMethod</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Method">Method</a><a href="src/Codec-Compression-Zlib-Stream.html#deflateMethod" class="link">Source</a></p><div class="doc"><p>'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.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:WindowBits" class="def">WindowBits</a>  <a href="src/Codec-Compression-Zlib-Stream.html#WindowBits" class="link">Source</a></p><div class="doc"><p>This specifies the size of the compression window. Larger values of this
 parameter result in better compression at the expense of higher memory
 usage.
</p><p>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 <code>8..15</code> which corresponds
 to compression window sizes of 256b to 32Kb. The default is 15 which is also
 the maximum size.
</p><p>The total amount of memory used depends on the window bits and the
 <code><a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></code>. See the <code><a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></code> for the details.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:WindowBits" class="def">WindowBits</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:DefaultWindowBits" class="def">DefaultWindowBits</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultWindowBits" class="def">defaultWindowBits</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a><a href="src/Codec-Compression-Zlib-Stream.html#defaultWindowBits" class="link">Source</a></p><div class="doc"><p>The default <code><a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></code> is 15 which is also the maximum size.
</p></div></div><div class="top"><p class="src"><a name="v:windowBits" class="def">windowBits</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a><a href="src/Codec-Compression-Zlib-Stream.html#windowBits" class="link">Source</a></p><div class="doc"><p>A specific compression window size, specified in bits in the range <code>8..15</code>
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:MemoryLevel" class="def">MemoryLevel</a>  <a href="src/Codec-Compression-Zlib-Stream.html#MemoryLevel" class="link">Source</a></p><div class="doc"><p>The <code><a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></code> 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.
</p><p>The total amount of memory used for compression depends on the <code><a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></code>
 and the <code><a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a></code>. For decompression it depends only on the
 <code><a href="Codec-Compression-Zlib-Internal.html#t:WindowBits">WindowBits</a></code>. The totals are given by the functions:
</p><pre> compressTotal windowBits memLevel = 4 * 2^windowBits + 512 * 2^memLevel
 decompressTotal windowBits = 2^windowBits
</pre><p>For example, for compression with the default <code>windowBits = 15</code> and
 <code>memLevel = 8</code> uses <code>256Kb</code>. So for example a network server with 100
 concurrent compressed streams would use <code>25Mb</code>. The memory per stream can be
 halved (at the cost of somewhat degraded and slower compressionby) by
 reducing the <code>windowBits</code> and <code>memLevel</code> by one.
</p><p>Decompression takes less memory, the default <code>windowBits = 15</code> corresponds
 to just <code>32Kb</code>.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:DefaultMemoryLevel" class="def">DefaultMemoryLevel</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:MinMemoryLevel" class="def">MinMemoryLevel</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:MaxMemoryLevel" class="def">MaxMemoryLevel</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:MemoryLevel" class="def">MemoryLevel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultMemoryLevel" class="def">defaultMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#defaultMemoryLevel" class="link">Source</a></p><div class="doc"><p>The default memory level. (Equivalent to <code><code><a href="Codec-Compression-Zlib-Internal.html#v:memoryLevel">memoryLevel</a></code> 8</code>)
</p></div></div><div class="top"><p class="src"><a name="v:minMemoryLevel" class="def">minMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#minMemoryLevel" class="link">Source</a></p><div class="doc"><p>Use minimum memory. This is slow and reduces the compression ratio.
 (Equivalent to <code><code><a href="Codec-Compression-Zlib-Internal.html#v:memoryLevel">memoryLevel</a></code> 1</code>)
</p></div></div><div class="top"><p class="src"><a name="v:maxMemoryLevel" class="def">maxMemoryLevel</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#maxMemoryLevel" class="link">Source</a></p><div class="doc"><p>Use maximum memory for optimal compression speed.
 (Equivalent to <code><code><a href="Codec-Compression-Zlib-Internal.html#v:memoryLevel">memoryLevel</a></code> 9</code>)
</p></div></div><div class="top"><p class="src"><a name="v:memoryLevel" class="def">memoryLevel</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:MemoryLevel">MemoryLevel</a><a href="src/Codec-Compression-Zlib-Stream.html#memoryLevel" class="link">Source</a></p><div class="doc"><p>A specific level in the range <code>1..9</code>
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:CompressionStrategy" class="def">CompressionStrategy</a>  <a href="src/Codec-Compression-Zlib-Stream.html#CompressionStrategy" class="link">Source</a></p><div class="doc"><p>The strategy parameter is used to tune the compression algorithm.
</p><p>The strategy parameter only affects the compression ratio but not the
 correctness of the compressed output even if it is not set appropriately.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:DefaultStrategy" class="def">DefaultStrategy</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:Filtered" class="def">Filtered</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:HuffmanOnly" class="def">HuffmanOnly</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:defaultStrategy" class="def">defaultStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a><a href="src/Codec-Compression-Zlib-Stream.html#defaultStrategy" class="link">Source</a></p><div class="doc"><p>Use this default compression strategy for normal data.
</p></div></div><div class="top"><p class="src"><a name="v:filteredStrategy" class="def">filteredStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a><a href="src/Codec-Compression-Zlib-Stream.html#filteredStrategy" class="link">Source</a></p><div class="doc"><p>Use 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
 <code>defaultCompressionStrategy</code> and <code>huffmanOnlyCompressionStrategy</code>.
</p></div></div><div class="top"><p class="src"><a name="v:huffmanOnlyStrategy" class="def">huffmanOnlyStrategy</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:CompressionStrategy">CompressionStrategy</a><a href="src/Codec-Compression-Zlib-Stream.html#huffmanOnlyStrategy" class="link">Source</a></p><div class="doc"><p>Use the Huffman-only compression strategy to force Huffman encoding only
 (no string match).
</p></div></div><h1 id="g:4">Low-level API to get explicit error reports
</h1><div class="top"><p class="src"><a name="v:decompressWithErrors" class="def">decompressWithErrors</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:Format">Format</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressParams">DecompressParams</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a><a href="src/Codec-Compression-Zlib-Internal.html#decompressWithErrors" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Codec-Compression-Zlib-Internal.html#v:decompress">decompress</a></code> but returns a <code><a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a></code> data structure that
 contains an explicit representation of the error conditions that one may
 encounter when decompressing.
</p><p>Note that in addition to errors in the input data, it is possible for other
 unexpected errors to occur, such as out of memory, or finding the wrong
 version of the zlib C library, these are still thrown as exceptions (because
 representing them as data would make this function impure).
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:DecompressStream" class="def">DecompressStream</a>  <a href="src/Codec-Compression-Zlib-Internal.html#DecompressStream" class="link">Source</a></p><div class="doc"><p>A sequence of chunks of data produced from decompression.
</p><p>The difference from a simple list is that it contains a representation of
 errors as data rather than as exceptions. This allows you to handle error
 conditions explicitly.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:StreamEnd" class="def">StreamEnd</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:StreamChunk" class="def">StreamChunk</a> <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString.html#t:ByteString">ByteString</a> <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:StreamError" class="def">StreamError</a> <a href="Codec-Compression-Zlib-Internal.html#t:DecompressError">DecompressError</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>An error code and a human readable error message.
</p></td></tr></table></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:DecompressError" class="def">DecompressError</a>  <a href="src/Codec-Compression-Zlib-Internal.html#DecompressError" class="link">Source</a></p><div class="doc"><p>The possible error cases when decompressing a stream.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:TruncatedInput" class="def">TruncatedInput</a></td><td class="doc"><p>The compressed data stream ended prematurely. This may happen if the
 input data stream was truncated.
</p></td></tr><tr><td class="src"><a name="v:DictionaryRequired" class="def">DictionaryRequired</a></td><td class="doc"><p>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
 zlib binding does not currently support custom dictionaries. This error
 is for when we encounter a compressed stream that needs a dictionary.
</p></td></tr><tr><td class="src"><a name="v:DataError" class="def">DataError</a></td><td class="doc"><p>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 <code><a href="Codec-Compression-Zlib-Internal.html#v:StreamEnd">StreamEnd</a></code>.
</p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:foldDecompressStream" class="def">foldDecompressStream</a> ::  (<a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; a -&gt; a) -&gt; a -&gt; (<a href="Codec-Compression-Zlib-Internal.html#t:DecompressError">DecompressError</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a) -&gt; <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a> -&gt; a<a href="src/Codec-Compression-Zlib-Internal.html#foldDecompressStream" class="link">Source</a></p><div class="doc"><p>Fold an <code>DecompressionStream</code>. Just like <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-List.html#v:foldr">foldr</a></code> but with an extra error
 case. For example to convert to a list and translate the errors into
 exceptions:
</p><pre> foldDecompressStream (:) [] (\code msg -&gt; error msg)
</pre></div></div><div class="top"><p class="src"><a name="v:fromDecompressStream" class="def">fromDecompressStream</a> :: <a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a><a href="src/Codec-Compression-Zlib-Internal.html#fromDecompressStream" class="link">Source</a></p><div class="doc"><p>Convert a <code><a href="Codec-Compression-Zlib-Internal.html#t:DecompressStream">DecompressStream</a></code> to a lazy <code>ByteString</code>. If any decompression
 errors are encountered then they are thrown as exceptions.
</p><p>This is a special case of <code><a href="Codec-Compression-Zlib-Internal.html#v:foldDecompressStream">foldDecompressStream</a></code>.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>