adler32 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+23/−16 lines, 3 filesdep ~basedep ~bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, bytestring
API changes (from Hackage documentation)
+ Data.Digest.Adler32: instance Data.Semigroup.Semigroup Data.Digest.Adler32.Adler32
- Data.Digest.Adler32: class Adler32Src a where adler32 = extractAdler32 . adler32' adler32Update c s = extractAdler32 $ makeAdler32 c (0 :: Word32) <> adler32' s adler32' = adler32Update' mempty
+ Data.Digest.Adler32: class Adler32Src a
Files
- ChangeLog.md +4/−0
- adler32.cabal +6/−6
- src/Data/Digest/Adler32.hs +13/−10
ChangeLog.md view
@@ -1,3 +1,7 @@+#### 0.1.2.0 *2018-03-15*++* Fix compatibility with base-4.11/GHC 8.4+ #### 0.1.1.0 *2016-01-25* * Introduce the `adler32Update'` method to the `Adler32Src` class.
adler32.cabal view
@@ -1,17 +1,17 @@ name: adler32-version: 0.1.1.0+version: 0.1.2.0 synopsis: An implementation of Adler-32, supporting rolling checksum operation description: This package provides an implementation of the Adler-32 checksum algorithm.- In supports a rolling checksum mode, i.e. the checksum of a sliding window+ 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 @zlib@- will be used. This can be disabled in which case a pure haskell- implementation will be used instead. The haskell version is 2 to 3 times- slower on my system.+ 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. homepage: https://github.com/redneb/hs-adler32 bug-reports: https://github.com/redneb/hs-adler32/issues license: BSD3@@ -36,7 +36,7 @@ library exposed-modules: Data.Digest.Adler32 -- other-modules: - build-depends: base >=4.6 && <5+ build-depends: base >=4.9 && <5 , bytestring >=0.10.2 hs-source-dirs: src default-language: Haskell2010
src/Data/Digest/Adler32.hs view
@@ -37,10 +37,7 @@ import qualified Data.ByteString.Lazy as BL import Data.Word (Word8, Word32) import Data.Bits (unsafeShiftL, unsafeShiftR, (.|.), (.&.))-import Data.Monoid ((<>))-#if !MIN_VERSION_base(4,8,0)-import Data.Monoid (Monoid(..))-#endif+import Data.Semigroup (Semigroup(..)) #ifdef USE_ZLIB import qualified Foreign as F@@ -67,7 +64,7 @@ adler32' = adler32Update' mempty {-# INLINE adler32' #-} - -- | Similar to 'adler32' except that it operates on 'Adler32' values.+ -- | Similar to 'adler32update' except that it operates on 'Adler32' values. -- An 'Adler32' value can also be updated with 'adler32'' in conjunction -- with the @Monoid@ instance of that type. adler32Update' :: Adler32 -> a -> Adler32@@ -137,16 +134,22 @@ instance Adler32Src BL.ByteString where adler32Update' = BL.foldlChunks (\c s -> c <> adler32' s) +instance Semigroup Adler32 where+ Adler32 a1 b1 l1 <> Adler32 a2 b2 l2 =+ Adler32 (mod0 $ a1m1 + a2) b (mod0 $ l1 + l2)+ where+ b = mod1 $ b1 + b2 + l2 * a1m1+ a1m1 = if a1 == 0 then base - 1 else a1 - 1+ -- | 'mempty' is the checksum of the empty message and '<>' computes the -- checksum of the concatenation of two messages. '<>' is an /O(1)/ -- operation. instance Monoid Adler32 where mempty = Adler32 1 0 0- mappend (Adler32 a1 b1 l1) (Adler32 a2 b2 l2) =- Adler32 (mod0 $ a1m1 + a2) b (mod0 $ l1 + l2)- where- b = mod1 $ b1 + b2 + l2 * a1m1- a1m1 = if a1 == 0 then base - 1 else a1 - 1++#if !(MIN_VERSION_base(4,11,0))+ mappend = (<>)+#endif -- | /O(1)/. If @c@ is the checksum of a message that starts with the -- byte @d1@ then @adler32SlideL d1 c d2@ is the checksum of the message