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


-- | An implementation of Adler-32, supporting rolling checksum operation
--   
--   This package provides an implementation of the Adler-32 checksum
--   algorithm. It supports a rolling checksum mode, i.e. the checksum of a
--   sliding window of the input message can be computed efficiently. It
--   also supports compounding, i.e. the checksum of the concatenation of
--   two messages can be efficiently computed from the checksums of the two
--   parts.
--   
--   By default, the highly optimized implementation of Adler-32 from
--   <tt>zlib</tt> will be used. This can be disabled, in which case a pure
--   haskell implementation will be used instead. On my system, the haskell
--   version is 2 to 3 times slower.
@package adler32
@version 0.1.2.0


-- | An implementation of the Adler-32 checksum algorithm. There are two
--   ways to use this module:
--   
--   <ul>
--   <li><a>adler32</a> and <a>adler32Update</a> which use <a>Word32</a>
--   for checksums,</li>
--   <li><a>adler32'</a> and <a>adler32Update'</a> which use the abstract
--   type <a>Adler32</a> for checksums. This mode is slightly more
--   low-level (<a>extractAdler32</a> has to be used to obtain a
--   <a>Word32</a> for the checksum), but it supports some additional
--   operations such rolling checksum and compounding.</li>
--   </ul>
module Data.Digest.Adler32

-- | Types of messages for which the Adler-32 checksum can be computed.
class Adler32Src a

-- | Compute the Adler-32 checksum of a <tt>ByteString</tt>.
adler32 :: Adler32Src a => a -> Word32

-- | Update the checksum of a message by providing a <tt>ByteString</tt> to
--   be appended to the original message.
adler32Update :: Adler32Src a => Word32 -> a -> Word32

-- | Similar to <a>adler32</a> except that an <a>Adler32</a> value is
--   returned.
adler32' :: Adler32Src a => a -> Adler32

-- | Similar to <tt>adler32update</tt> except that it operates on
--   <a>Adler32</a> values. An <a>Adler32</a> value can also be updated
--   with <a>adler32'</a> in conjunction with the <tt>Monoid</tt> instance
--   of that type.
adler32Update' :: Adler32Src a => Adler32 -> a -> Adler32

-- | An abstract representation of an Adler-32 checksum. Forcing a value of
--   this type to whnf will cause it to be evaluated completely.
data Adler32

-- | Extract the actual Adler-32 checksum from a <a>Adler32</a> object.
extractAdler32 :: Adler32 -> Word32

-- | <tt>makeAdler32 c l</tt> will create an <a>Adler32</a> object that
--   corresponds to a message whose checksum is <tt>c</tt> and length is
--   <tt>l</tt>.
makeAdler32 :: Integral a => Word32 -> a -> Adler32

-- | <i>O(1)</i>. If <tt>c</tt> is the checksum of a message that starts
--   with the byte <tt>d1</tt> then <tt>adler32SlideL d1 c d2</tt> is the
--   checksum of the message that is obtained by removing the first byte
--   and appending the byte <tt>d2</tt> at the end of the original message.
--   It is the caller's responsibility to ensure that the original message
--   starts with the byte <tt>d1</tt>.
adler32SlideL :: Word8 -> Adler32 -> Word8 -> Adler32

-- | <i>O(1)</i>. Similar to <a>adler32SlideL</a> except that it slides the
--   checksum window to the other direction, i.e. in <tt>adler32SlideR d1 c
--   d2</tt> the byte <tt>d2</tt> will be removed from the end of the
--   original message and the byte <tt>d1</tt> will be prepended to its
--   beginning. It is the caller's responsibility to ensure that the
--   original message ends with the byte <tt>d2</tt>.
adler32SlideR :: Word8 -> Adler32 -> Word8 -> Adler32

-- | <i>O(1)</i>. Given the checksum of a message, this function returns
--   the checksum of that message with a byte appended to it.
adler32AppendByte :: Adler32 -> Word8 -> Adler32

-- | <i>O(1)</i>. Given the checksum of a message, this function returns
--   the checksum of that message its last byte removed from it. The value
--   of that byte has to be provided by the caller and the behavior of the
--   function is unspecified if that value is incorrect.
adler32UnAppendByte :: Adler32 -> Word8 -> Adler32

-- | <i>O(1)</i>. Given the checksum of a message, this function returns
--   the checksum of that message with a byte prepended to it.
adler32PrependByte :: Word8 -> Adler32 -> Adler32

-- | <i>O(1)</i>. Given the checksum of a message, this function returns
--   the checksum of that message its first byte removed from it. The value
--   of that byte has to be provided by the caller and the behavior of the
--   function is unspecified if that value is incorrect.
adler32UnPrependByte :: Word8 -> Adler32 -> Adler32

-- | <i>O(1)</i>. If <tt>s1</tt> and <tt>s2</tt> are two messages then
--   <tt>adler32UnAppend c c2</tt> returns the checksum of <tt>s1</tt>
--   where <tt>c</tt> is the checksum of <tt>s1 &lt;&gt; s2</tt> and
--   <tt>c2</tt> is the checksum of <tt>s2</tt>.
adler32UnAppend :: Adler32 -> Adler32 -> Adler32

-- | <i>O(1)</i>. If <tt>s1</tt> and <tt>s2</tt> are two messages then
--   <tt>adler32UnAppend c1 c</tt> returns the checksum of <tt>s2</tt>
--   where <tt>c</tt> is the checksum of <tt>s1 &lt;&gt; s2</tt> and
--   <tt>c1</tt> is the checksum of <tt>s1</tt>.
adler32UnPrepend :: Adler32 -> Adler32 -> Adler32
instance GHC.Classes.Ord Data.Digest.Adler32.Adler32
instance GHC.Classes.Eq Data.Digest.Adler32.Adler32
instance Data.Digest.Adler32.Adler32Src Data.ByteString.Internal.ByteString
instance Data.Digest.Adler32.Adler32Src Data.ByteString.Lazy.Internal.ByteString
instance GHC.Show.Show Data.Digest.Adler32.Adler32
instance GHC.Base.Semigroup Data.Digest.Adler32.Adler32
instance GHC.Base.Monoid Data.Digest.Adler32.Adler32
