shannon-fano-1.0.0.0: Shannon-fano compression algorithm in Haskell

Safe HaskellSafe
LanguageHaskell2010

Codec.Compression.ShannonFano

Synopsis

Documentation

data DecodeTableError Source #

Decode table error can happen when the wrong code table is provided.

Constructors

DecodeTableError 

frequency Source #

Arguments

:: Input

Input string

-> Table Int

Resulting table

Gives the frequency table of all characters in a string.

probability Source #

Arguments

:: Input

Input string

-> Table Float

Resulting table

Gives the probability table of all characters in a string.

genCodeTable Source #

Arguments

:: Input

Input string

-> Table ByteString

Resulting code table

Generates a DecodeTable

compress Source #

Arguments

:: Input

Input string

-> ByteString

Result compressed

Given a 'Table ByteString' compresses it by applying the Shannon-fano algorithm.

decompress Source #

Arguments

:: ByteString

Coded input to decompress

-> Table ByteString

Code table associated with the input

-> Maybe Input

Result decompressed

Decompresses a compressed ByteString, given a code table

This fails if the code table does not have an entry for a given character.

compressToFile Source #

Arguments

:: Handle

Handle from where data will be read

-> String

Output file name

-> IO () 

Reads contents from a handle and compresses it to a file.

The resulting files are: - '<filename>' <- binary compressed file - '<filename>.dat' <- contains the decoding table

decompressFromFile Source #

Arguments

:: Handle

Handle from where compressed data will be read

-> Table ByteString

Decode table

-> String

Output file name

-> IO (Either DecodeTableError ()) 

Decompresses a file given a decoding table file and a compressed compressed file.