HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesnappy-c-0.1.1Haskell2010

Codec.Compression.SnappyC.Framed

Frame format Snappy compression/decompression. See the framing format description here: https://github.com/google/snappy/blob/main/framing_format.txt

Intended for qualified import:

import Codec.Compression.SnappyC.Framed qualified as Snappy
  • 7 types
  • 16 values
  • Packagesnappy-c-0.1.1
  • Exports23
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFramed.hs

Compression

1 declaration

Compression with custom parameters

datadata EncodeParams
#

Determines how much data is put in each Snappy frame and whether it is compressed.

Constructors

Instances3Eq, Show, Default
  • Eq EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Show EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Default EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
newtypenewtype FrameSize
#

Number of bytes of uncompressed data.

Instances3Eq, Show, Default
  • Eq FrameSizeDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Show FrameSizeDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Default FrameSizeDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
datadata Threshold
#

Compression threshold, with explicit AlwaysCompress and NeverCompress settings.

Constructors

  • AlwaysCompress

    Compress everything

  • NeverCompress

    Compress nothing

  • Ratio !Double

    Uncompressed size divided by compressed size.

    Only produce compressed frames if the compression ratio for the data is equal to or above this threshold.

    A higher threshold may result in less frames holding compressed data, and thus faster decompression/decoding.

    According to Google, the typical highest compression ratio that Snappy achieves is about 4, so a Ratio of > 4.0 should be similar to NeverCompress, while a Ratio of < 7/8 should be similar to AlwaysCompress.

Instances3Eq, Show, Default
  • Eq ThresholdDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Show ThresholdDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Default ThresholdDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat

Decompression

3 declarations

Decompress the input using Snappy.

The input stream is expected to be in the official Snappy frame format.

Note: The extra laziness of this function (compared to decompress') comes at the cost of potential exceptions during decompression.

Deprecated. Consider using decompress or decompressStep' instead

Decompress the input using Snappy.

The input stream is expected to be in the official Snappy frame format. Evaluates to a DecodeFailure if the input stream is ill-formed.

WARNING: This function is not as lazy as you might hope. To determine whether the result is a DecodeFailure, it must load the entire source ByteString into memory during decompression. Use either decompressWithParams or the incremental decompressStep' instead. If you are truly okay with the extra memory overhead, you may ignore this warning.

Decompression with custom parameters

datadata DecodeParams
#

Decode parameters

Constructors

  • DecodeParams
    • verifyChecksum :: !Bool

      Verify the uncompressed data checksums during decompression

      Defaults to False. Even if we don't verify the CRC, if the data is not Snappy compressed then decompression will likely still fail due to failing to decode the frame headers.

      To enable this, use the incremental API (decompressStep). Note that checksum verification adds a significant overhead to decompression.

Instances3Eq, Show, Default
  • Eq DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Show DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat
  • Default DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat

Deprecated. Consider using decompressWithParams or decompressStep' instead

Decompress the input using Snappy with the given DecodeParams.

The input stream is expected to be in the official Snappy frame format. Evaluates to a DecodeFailure if the input stream is ill-formed.

WARNING: This function is not as lazy as you might hope. To determine whether the result is a DecodeFailure, it must load the entire source ByteString into memory during decompression. Use either decompressWithParams or the incremental decompressStep' instead. If you are truly okay with the extra memory overhead, you may ignore this warning.

Low-level incremental API

0 declarations

Compression

newtypenewtype Encoder
#

Buffers uncompressed data for compression.

Instances1Show
  • Show EncoderDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat

Initialize an Encoder with the given maximum number of bytes of uncompressed data to include in frames resulting from the Encoder. If the given number of bytes is not in the inclusive range [1 .. 65536], 65536 is used.

The ByteString holds the Snappy stream identifier frame that must be included at the start of every Snappy frame encoded stream.

Decompression

datadata Decoder
#

Buffers compressed data for decompression and holds some useful decompression state.

Instances1Show
  • Show DecoderDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormat