snappy-hs: Snappy compression library.

[ codec, library, mit, program ] [ Propose Tags ] [ Report a vulnerability ]

A pure Haskell implementation of the Snappy compression spec.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.1.0, 0.1.2.0
Change log CHANGELOG.md
Dependencies base (>=4.11 && <5), bytestring (>=0.11 && <0.14), deepseq (>=1.4 && <1.6), snappy-hs (>=0.1 && <1), time (>=1.14 && <1.15) [details]
License MIT
Author Michael Chavinda
Maintainer mschavinda@gmail.com
Uploaded by mchav at 2026-06-20T03:22:24Z
Category Codec
Home page https://github.com/mchav/snappy-hs
Bug tracker https://github.com/mchav/snappy-hs/issues
Source repo head: git clone https://github.com/mchav/snappy-hs
Distributions Stackage:0.1.2.0
Reverse Dependencies 2 direct, 8 indirect [details]
Executables snappy-bench, snappy-hs
Downloads 172 total (30 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-06-20 [all 1 reports]

Readme for snappy-hs-0.1.2.0

[back to package description]

snappy-hs

A pure Haskell implementation of the Snappy compression format.

This library prioritizes portability and simplicity over raw speed. It works reliably across platforms without requiring a C toolchain or dealing with FFI.

Performance

Measured against the native C library (the snappy bindings) on the Google Snappy test corpus, GHC 9.12 / aarch64, library built with -O2:

dataset (size) decompress vs C compress vs C
html (100 KB) 1.8x 2.3x
alice29.txt (149 KB) 1.5x 3.1x
geo.protodata (116 KB) 1.8x 2.4x
urls.10K (686 KB) 2.1x 2.6x
fireworks.jpeg (120 KB, incompressible) 1.0x 1.8x

Decompression runs at roughly C parity (~1-2x) and compression is ~2-3x of C. The gap that remains is GHC's native code generator versus a C compiler, not the algorithm — the encoder mirrors C Snappy's CompressFragment (skip heuristic, word-at-a-time match extension, input-sized hash table). Output is validated to be byte-compatible with the C library in both directions.

Reproduce with cabal bench (criterion, needs the C snappy library installed) or cabal run snappy-bench (pure, no C dependency).

When to use

  • You want cross-platform Snappy encode/decode with a pure Haskell dependency stack
  • You’d rather avoid C FFI and the build/packaging complexity that comes with it

When not to use

  • You need maximum throughput (use the native library or an FFI-based binding instead). You would get a lot of mileage from the library too however.