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


-- | LZMA/XZ compression and decompression
--   
--   This package provides a pure interface for compressing and
--   decompressing <a>LZMA (Lempel–Ziv–Markov chain algorithm)</a> streams
--   of data represented as lazy <tt>ByteString</tt>s. A monadic
--   incremental interface is provided as well. This package relies on the
--   <a>liblzma C library</a>.
--   
--   The following packages are based on this package and provide API
--   support for popular streaming frameworks:
--   
--   <ul>
--   <li><a>lzma-streams</a> (for <a>io-streams</a>)</li>
--   <li><a>pipes-lzma</a> (for <a>pipes</a>)</li>
--   <li><a>lzma-conduit</a> (for <a>conduit</a>)</li>
--   </ul>
@package lzma
@version 0.0.1.0


-- | Compression and decompression of data streams in the lzma/xz format
--   
--   See also the XZ Utils home page: <a>http://tukaani.org/xz/</a>
module Codec.Compression.Lzma

-- | Compress lazy <a>ByteString</a> into <tt>.xz</tt> format using
--   <a>defaultCompressParams</a>.
compress :: ByteString -> ByteString

-- | Decompress lazy <a>ByteString</a> from the <tt>.xz</tt> format
decompress :: ByteString -> ByteString

-- | Like <a>compress</a> but with the ability to specify various
--   compression parameters. Typical usage:
--   
--   <pre>
--   compressWith defaultCompressParams { compress... = ... }
--   </pre>
compressWith :: CompressParams -> ByteString -> ByteString

-- | Like <a>decompress</a> but with the ability to specify various
--   decompression parameters. Typical usage:
--   
--   <pre>
--   decompressWith defaultDecompressParams { decompress... = ... }
--   </pre>
decompressWith :: DecompressParams -> ByteString -> ByteString
data CompressStream m

-- | Compression process requires input to proceed. You can either flush
--   the stream (first field), supply an input chunk (second field), or
--   signal the end of input (via empty chunk).
CompressInputRequired :: m (CompressStream m) -> (ByteString -> m (CompressStream m)) -> CompressStream m

-- | Output chunk available.
CompressOutputAvailable :: !ByteString -> m (CompressStream m) -> CompressStream m
CompressStreamEnd :: CompressStream m

-- | Incremental compression in the <a>IO</a> monad.
compressIO :: CompressParams -> IO (CompressStream IO)

-- | Incremental compression in the lazy <a>ST</a> monad.
compressST :: CompressParams -> ST s (CompressStream (ST s))
data DecompressStream m

-- | Decoding process requires input to proceed. An empty <a>ByteString</a>
--   chunk signals end of input.
DecompressInputRequired :: (ByteString -> m (DecompressStream m)) -> DecompressStream m

-- | Decompressed output chunk available.
DecompressOutputAvailable :: !ByteString -> m (DecompressStream m) -> DecompressStream m

-- | Decoded stream is finished. Any unconsumed leftovers from the input
--   stream are returned via the <a>ByteString</a> field
DecompressStreamEnd :: ByteString -> DecompressStream m
DecompressStreamError :: !LzmaRet -> DecompressStream m

-- | Incremental decompression in the <a>IO</a> monad.
decompressIO :: DecompressParams -> IO (DecompressStream IO)

-- | Incremental decompression in the lazy <a>ST</a> monad.
decompressST :: DecompressParams -> ST s (DecompressStream (ST s))
data LzmaRet
LzmaRetOK :: LzmaRet
LzmaRetStreamEnd :: LzmaRet
LzmaRetUnsupportedCheck :: LzmaRet
LzmaRetGetCheck :: LzmaRet
LzmaRetMemError :: LzmaRet
LzmaRetMemlimitError :: LzmaRet
LzmaRetFormatError :: LzmaRet
LzmaRetOptionsError :: LzmaRet
LzmaRetDataError :: LzmaRet
LzmaRetBufError :: LzmaRet
LzmaRetProgError :: LzmaRet

-- | The default set of parameters for compression. This is typically used
--   with the <tt>compressWith</tt> function with specific parameters
--   overridden.
defaultCompressParams :: CompressParams

-- | Set of parameters for compression. The defaults are
--   <a>defaultCompressParams</a>.
data CompressParams

-- | <a>CompressParams</a> field: Specify type of integrity check
compressIntegrityCheck :: CompressParams -> IntegrityCheck

-- | <a>CompressParams</a> field: See documentation of
--   <a>CompressionLevel</a>
compressLevel :: CompressParams -> CompressionLevel

-- | <a>CompressParams</a> field: Enable slower variant of the
--   <tt>lzmaCompLevel</tt> preset, see <tt>xz(1)</tt> man-page for
--   details.
compressLevelExtreme :: CompressParams -> Bool

-- | Number of threads to use. It must be greater than zero.
compressThreads :: CompressParams -> Int

-- | Integrity check type (only supported when compressing <tt>.xz</tt>
--   files)
data IntegrityCheck

-- | disable integrity check (not recommended)
IntegrityCheckNone :: IntegrityCheck

-- | CRC32 using the polynomial from IEEE-802.3
IntegrityCheckCrc32 :: IntegrityCheck

-- | CRC64 using the polynomial from ECMA-182
IntegrityCheckCrc64 :: IntegrityCheck

-- | SHA-256
IntegrityCheckSha256 :: IntegrityCheck

-- | Compression level presets that define the tradeoff between
--   computational complexity and compression ratio
--   
--   <a>CompressionLevel0</a> has the lowest compression ratio as well as
--   the lowest memory requirements, whereas <a>CompressionLevel9</a> has
--   the highest compression ratio and can require over 600MiB during
--   compression (and over 60MiB during decompression). The <a>man-page for
--   xz(1)</a> contains more detailed information with tables describing
--   the properties of all compression level presets.
--   
--   <a>CompressionLevel6</a> is the default setting in
--   <a>defaultCompressParams</a> as it provides a good trade-off and
--   matches the default of the <tt>xz(1)</tt> tool.
data CompressionLevel
CompressionLevel0 :: CompressionLevel
CompressionLevel1 :: CompressionLevel
CompressionLevel2 :: CompressionLevel
CompressionLevel3 :: CompressionLevel
CompressionLevel4 :: CompressionLevel
CompressionLevel5 :: CompressionLevel
CompressionLevel6 :: CompressionLevel
CompressionLevel7 :: CompressionLevel
CompressionLevel8 :: CompressionLevel
CompressionLevel9 :: CompressionLevel

-- | The default set of parameters for decompression. This is typically
--   used with the <tt>decompressWith</tt> function with specific
--   parameters overridden.
defaultDecompressParams :: DecompressParams

-- | Set of parameters for decompression. The defaults are
--   <a>defaultDecompressParams</a>.
data DecompressParams

-- | <a>DecompressParams</a> field: If set, abort if decoded stream has no
--   integrity check.
decompressTellNoCheck :: DecompressParams -> Bool

-- | <a>DecompressParams</a> field: If set, abort (via
--   <a>LzmaRetGetCheck</a>) if decoded stream integrity check is
--   unsupported.
decompressTellUnsupportedCheck :: DecompressParams -> Bool

-- | <a>DecompressParams</a> field: If set, abort (via
--   <a>LzmaRetGetCheck</a>) as soon as the type of the integrity check has
--   been detected.
decompressTellAnyCheck :: DecompressParams -> Bool

-- | <a>DecompressParams</a> field: If set, concatenated files as decoded
--   seamless.
decompressConcatenated :: DecompressParams -> Bool

-- | <a>DecompressParams</a> field: If set, legacy <tt>.lzma</tt>-encoded
--   streams are allowed too.
decompressAutoDecoder :: DecompressParams -> Bool

-- | <a>DecompressParams</a> field: decompressor memory limit. Set to
--   <a>maxBound</a> to disable memory limit.
decompressMemLimit :: DecompressParams -> Word64
