-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Lenses for zlib
--   
--   Lenses for zlib
@package zlib-lens
@version 0.1.2.1


-- | <tt>lens</tt> support for the <tt>zlib</tt> library
module Codec.Compression.Zlib.Lens

-- | Compresses a <a>ByteString</a> using the <a>gzip</a> compression
--   format.
--   
--   <pre>
--   <a>gzipped</a> = <a>compressed</a> <a>gzip</a>
--   <a>gzipped</a> = <a>gzipped'</a> <a>defaultParams</a>
--   </pre>
gzipped :: Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the <a>zlib</a> compression
--   format.
--   
--   <pre>
--   <a>zlibbed</a> = <a>compressed</a> <a>zlib</a>
--   <a>zlibbed</a> = 'zlibbed\'' <a>defaultParams</a>
--   </pre>
zlibbed :: Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the <a>deflate</a> compression
--   format.
--   
--   <pre>
--   <a>deflated</a> = <a>compressed</a> <a>deflate</a>
--   <a>deflated</a> = <a>deflated'</a> <a>defaultParams</a>
--   </pre>
deflated :: Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the given compression format.
--   
--   <pre>
--   <a>compressed</a> fmt = <a>compressed'</a> fmt <a>defaultParams</a>
--   </pre>
compressed :: Format -> Iso' ByteString ByteString

-- | The format used for compression or decompression. There are three
--   variations.
data Format

-- | The <a>gzip</a> compression format.
gzip :: Format

-- | The <a>zlib</a> compression format.
zlib :: Format

-- | The <a>deflate</a> compression format.
deflate :: Format

-- | Compresses a <a>ByteString</a> using the <a>zlib</a> compression
--   format and the given advanced parameters.
--   
--   <pre>
--   <a>zlibbed</a> = <a>compressed</a> <a>zlib</a>
--   <a>zlibbed</a> = <a>zlibbed'</a> <a>defaultParams</a>
--   </pre>
zlibbed' :: Params -> Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the <a>gzip</a> compression
--   format and the given advanced parameters.
--   
--   <pre>
--   <a>gzipped</a> = <a>compressed</a> <a>gzip</a>
--   <a>gzipped</a> = <a>gzipped'</a> <a>defaultParams</a>
--   </pre>
gzipped' :: Params -> Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the <a>deflate</a> compression
--   format and the given advanced parameters.
--   
--   <pre>
--   <a>deflated</a> = <a>compressed</a> <a>deflate</a>
--   <a>deflated</a> = <a>deflated'</a> <a>defaultParams</a>
--   </pre>
deflated' :: Params -> Iso' ByteString ByteString

-- | Compresses a <a>ByteString</a> using the given compression format and
--   the given advanced parameters.
compressed' :: Format -> Params -> Iso' ByteString ByteString

-- | The advanced parameters needed by <a>gzipped'</a>, <a>zlibbed'</a>,
--   <a>deflated'</a>, and <a>compressed'</a>.
--   
--   Use <a>defaultParams</a> and the provided <tt>Lens</tt>es to construct
--   custom <a>Params</a>.
data Params

-- | The default advanced parameters for compression and decompression.
defaultParams :: Params

-- | The compression level.
levelC :: Lens' Params CompressionLevel

-- | The compression method.
methodC :: Lens' Params Method

-- | The number of bits in the compression window.
windowBitsC :: Lens' Params WindowBits

-- | The number of bits in the decompression window.
windowBitsD :: Lens' Params WindowBits

-- | The amount of memory allowed for the internal compression state.
memoryLevelC :: Lens' Params MemoryLevel

-- | The compression strategy.
strategyC :: Lens' Params CompressionStrategy

-- | The initial buffer size during compression.
bufferSizeC :: Lens' Params Int

-- | The initial buffer size during decompression.
bufferSizeD :: Lens' Params Int

-- | <a>Just</a> the custom (de)compression dictionary to use, or
--   <a>Nothing</a> to not use a custom dictionary.
dictionary :: Lens' Params (Maybe ByteString)

-- | 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.
data CompressionLevel

-- | The default compression level is 6 (that is, biased towards higher
--   compression at expense of speed).
defaultCompression :: CompressionLevel

-- | No compression, just a block copy.
noCompression :: CompressionLevel

-- | The fastest compression method (less compression)
bestSpeed :: CompressionLevel

-- | The slowest compression method (best compression).
bestCompression :: CompressionLevel

-- | A specific compression level between 0 and 9.
compressionLevel :: Int -> CompressionLevel

-- | The compression method
data Method

-- | '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.
deflateMethod :: Method

-- | 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 <tt>9..15</tt>
--   which corresponds to compression window sizes of 512b to 32Kb. The
--   default is 15 which is also the maximum size.
--   
--   The total amount of memory used depends on the window bits and the
--   <a>MemoryLevel</a>. See the <a>MemoryLevel</a> for the details.
data WindowBits

-- | The default <a>WindowBits</a> is 15 which is also the maximum size.
defaultWindowBits :: WindowBits

-- | A specific compression window size, specified in bits in the range
--   <tt>9..15</tt>
windowBits :: Int -> WindowBits

-- | The <a>MemoryLevel</a> 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
--   <a>WindowBits</a> and the <a>MemoryLevel</a>. For decompression it
--   depends only on the <a>WindowBits</a>. The totals are given by the
--   functions:
--   
--   <pre>
--   compressTotal windowBits memLevel = 4 * 2^windowBits + 512 * 2^memLevel
--   decompressTotal windowBits = 2^windowBits
--   </pre>
--   
--   For example, for compression with the default <tt>windowBits = 15</tt>
--   and <tt>memLevel = 8</tt> uses <tt>256Kb</tt>. So for example a
--   network server with 100 concurrent compressed streams would use
--   <tt>25Mb</tt>. The memory per stream can be halved (at the cost of
--   somewhat degraded and slower compressionby) by reducing the
--   <tt>windowBits</tt> and <tt>memLevel</tt> by one.
--   
--   Decompression takes less memory, the default <tt>windowBits = 15</tt>
--   corresponds to just <tt>32Kb</tt>.
data MemoryLevel

-- | The default memory level. (Equivalent to <tt><a>memoryLevel</a>
--   8</tt>)
defaultMemoryLevel :: MemoryLevel

-- | Use minimum memory. This is slow and reduces the compression ratio.
--   (Equivalent to <tt><a>memoryLevel</a> 1</tt>)
minMemoryLevel :: MemoryLevel

-- | Use maximum memory for optimal compression speed. (Equivalent to
--   <tt><a>memoryLevel</a> 9</tt>)
maxMemoryLevel :: MemoryLevel

-- | A specific level in the range <tt>1..9</tt>
memoryLevel :: Int -> MemoryLevel

-- | The 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.
data CompressionStrategy

-- | Use this default compression strategy for normal data.
defaultStrategy :: CompressionStrategy

-- | 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 <tt>defaultCompressionStrategy</tt> and
--   <tt>huffmanOnlyCompressionStrategy</tt>.
filteredStrategy :: CompressionStrategy

-- | Use the Huffman-only compression strategy to force Huffman encoding
--   only (no string match).
huffmanOnlyStrategy :: CompressionStrategy
