quicklz 1.5.0.2 → 1.5.0.3
raw patch · 3 files changed
+35/−9 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Codec/Compression/QuickLZ.hsc +22/−4
- quicklz.cabal +3/−3
- tests/Properties.hs +10/−2
Codec/Compression/QuickLZ.hsc view
@@ -11,14 +11,31 @@ -- -- This module provides a high level 'ByteString' interface to -- the QuickLZ library. More info about quicklz can be found here: --- http://quicklz.com +-- <http://quicklz.com> -- --- QuickLZ is fast and compresses very well. +-- QuickLZ is fast and compresses well. -- The library that is bundled with this version is QuickLZ v1.5.0, -- with the compression level set to 1. -- --- Streaming/enumerator interface coming soon. +-- Truthfully, the only laws that hold with this library are the following: -- +-- @(decompress . compress) == id@ +-- +-- @(decompress xs) == (decompress xs)@ +-- +-- Note that: +-- +-- @(compress xs) == (compress xs)@ +-- +-- Does not hold. +-- QuickLZ uses random data to seed part of the compression, so the lengths +-- and compressed results can differ. But they will always decompress back +-- to the same string, e.g., @compress@ is not referentially transparent, but +-- @decompress@ is (so don't go and insert compressed data as keys into any `Data.Map`s.) +-- +-- Arguably this is an abomination; nonetheless, this pure interface is a +-- nice abstraction. +-- module Codec.Compression.QuickLZ ( -- * Compressing and decompressing strict 'ByteString's compress -- :: S.ByteString -> S.ByteString @@ -47,7 +64,7 @@ SI.createAndTrim (S.length xs + 400) $ \output -> do U.unsafeUseAsCStringLen xs $ \(cstr,len) -> c_qlz_compress cstr output len compress_state - +{-# INLINEABLE compress #-} -- | Decompress the input 'ByteString'. decompress :: S.ByteString -> S.ByteString @@ -59,6 +76,7 @@ SI.createAndTrim sz $ \output -> do U.unsafeUseAsCString xs $ \cstr -> c_qlz_decompress cstr output decompress_state +{-# INLINEABLE decompress #-} -- -- Simple bindings to some constants
quicklz.cabal view
@@ -1,8 +1,8 @@ name: quicklz -version: 1.5.0.2 +version: 1.5.0.3 synopsis: binding to QuickLZ compression library description: - This package provides a high level binding to the QuickLZ (http:\/\/quicklz.com) library + This package provides a high level binding to the QuickLZ (<http:\\quicklz.com>) library for ByteStrings, under the GPLv2 license. QuickLZ is fast and compresses very well. . This package includes the QuickLZ 1.5.0 source code, with compression level 1 and streaming @@ -62,5 +62,5 @@ test-framework-quickcheck2 == 0.2.*, quicklz - ghc-options: -Wall + ghc-options: -Wall -fno-cse default-language: Haskell98
tests/Properties.hs view
@@ -9,9 +9,17 @@ main :: IO () main = defaultMain [ testGroup "simple" [ - testProperty "identity" prop_id + testProperty "compress identity" prop_id + , testProperty "decompress transparent" prop_decompress_id ] ] prop_id :: String -> Bool -prop_id (pack -> xs) = xs == (decompress . compress) xs +prop_id (pack -> xs) = + xs == (decompress . compress) xs + +prop_decompress_id :: String -> Bool +prop_decompress_id (pack -> xs) = + let z = compress xs + in (decompress z) == (decompress z) +