MyNixOS website logo
Description

Bindings to Google's Snappy: A fast compression library.

Snappy is a fast (de)compression library. It is written in C++, but a basic set of C bindings is also provided. Although the C bindings only support the "raw" Snappy format, this package provides support for the Snappy "frame" format on top of the raw C API, enabling extremely fast (de)compression of lazy (streamed) data.

snappy-c

CI Status Badge

Haskell bindings to the C API of Snappy: A fast compression library.

Usage

[!IMPORTANT] To use this package, you must have the Snappy library installed and visible to cabal.

If your build fails with a message like:

Error: cabal-3.10.1.0: Missing dependency on a foreign library:
* Missing (or bad) C library: snappy

You need to explicitly configure the include and library paths via cabal. One way to do so is to add something like this to your cabal.project configuration:

package snappy-c
  extra-include-dirs:
    /path/to/snappy/include
  extra-lib-dirs:
    /path/to/snappy/lib

In my case, on a mac using homebrew, the following suffices:

package snappy-c
  extra-lib-dirs:
    /opt/homebrew/lib
  extra-include-dirs:
    /opt/homebrew/include

We wouldn't need to do this if the Snappy library supported pkg-config configuration, but as of writing they do not.

Installing Snappy

The Snappy library is available most package managers.

Homebrew

brew install snappy

APT

apt-get install libsnappy-dev

Performance

snappy-c stays true to the speedy spirit of Snappy compression.

The package includes a benchmark suite that compares the compression, decompression, and roundtrip performance of this package against

Run the benchmarks with:

cabal run bench-snappy-c -- --time-limit 5 -o bench.html

[!IMPORTANT] To build the benchmarks, you will need to set extra-include-dirs and extra-lib-dirs for the snappy package as you did for snappy-c (see Usage).

Here's a screenshot from the generated bench.html file:

benchmark results

snappy-cli performance

See snappy-cli/README.md for a demonstration of the performance of this library in a CLI tool.

Metadata

Version

0.1.1

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows