Compress the input using Snappy.
The output stream is in Snappy frame format.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulesnappy-c-0.1.1Haskell2010
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 SnappyCompress the input using Snappy.
The output stream is in Snappy frame format.
Determines how much data is put in each Snappy frame and whether it is compressed.
Eq EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatShow EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatDefault EncodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatNumber of bytes of uncompressed data.
Compression threshold, with explicit AlwaysCompress and NeverCompress settings.
AlwaysCompressCompress everything
NeverCompressCompress nothing
Ratio !DoubleUncompressed 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.
Compress the input using Snappy with the given EncodeParams.
The output stream is in Snappy frame format.
The default frame size is 65536 bytes, which is the maximum allowed by the Snappy framing format description.
Create a FrameSize.
Must be within the inclusive range [ 1 .. 65536 ].
Unwrap a FrameSize
Possible failure modes for decompression.
Show DecodeFailureDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatException DecodeFailureDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatDecompress 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.
Decode parameters
DecodeParamsverifyChecksum :: !BoolVerify 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.
Eq DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatShow DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatDefault DecodeParamsDefined in snappy-c-0.1.1 · Codec.Compression.SnappyC.Internal.FrameFormatDecompress the input using Snappy with the given DecodeParams.
The input stream is expected to be in the official Snappy frame format.
Note: The extra laziness of this function (compared to decompressWithParams') comes at the cost of potential exceptions during decompression.
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.
Buffers uncompressed data for compression.
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.
Call to indicate no more input and flush the remaining data in the Encoder into a new frame.
If there is no more data in the Encoder, an empty list is returned.
Precondition: The buffer does not hold more data than the frameSize
in the EncodeParams. Use the postcondition of encodeBuffered to ensure
this.
Append the data to the Encoder buffer and do as much compression as possible.
Postconditions:
The resulting Encoder will not have more data in its buffer than the
chunkSize in the EncodeParams.
Each encoded frame will hold exactly one chunkSize worth of
uncompressed data.
Buffers compressed data for decompression and holds some useful decompression state.
The empty Decoder, in an initial state.
Append the data to the Decoder buffer and do as much decompression as possible.
Throws an exception if any DecodeFailure occurs.
Append the data to the Decoder buffer and do as much decompression as possible.
Note: This function is not as lazy as decompressStep, since it must completely decode the given chunk before providing a result.