quicklz-1.5.0.5: binding to QuickLZ compression library

Portabilityportable
Stabilityexperimental
Maintaineras@hacks.yi.org

Codec.Compression.QuickLZ

Contents

Description

This module provides a high level ByteString interface to the QuickLZ library. More info about quicklz can be found here: http://quicklz.com

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.

The following laws hold:

(decompress . compress) == id
(decompress xs) == (decompress xs)
(compress xs) == (compress xs)

A word of notice: QuickLZ, for inputs of less than 5 bytes in length, will generate different compression results for the same input on identical runs.

Because this behavior is not referentially transparent, we use a hack: merely short-circuit on an empty input, and always pad the input with 4 extra null bytes otherwise. This yields identical compression results for every input, giving compress the above nice law. On decompression, after yielding the resulting string from decompression, we cut the characters off.

Arguably this is an abomination; nonetheless, this pure interface is a nice abstraction.

Synopsis

Compressing and decompressing strict ByteStrings

compress :: ByteString -> ByteStringSource

Compresses the input ByteString.

decompress :: ByteString -> ByteStringSource

Decompress the input ByteString.

decompress' :: ByteString -> ByteStringSource

Decompress the input ByteString and save memory via overlapping decompression.