shannon-fano-0.1.0.0: Shannon-fano compression algorithm implementation in Haskell

Safe HaskellSafe
LanguageHaskell2010

Codec.Compression.ShannonFano

Synopsis

Documentation

frequency Source #

Arguments

:: String

Input string

-> Table Int

Resulting table

Gives the frequency table of all characters in a string.

probability Source #

Arguments

:: String

Input string

-> Table Float

Resulting table

Gives the probability table of all characters in a string.

compress Source #

Arguments

:: (Num a, Ord a) 
=> (String -> Table a)

frequency or probability can be applied

-> String

String to compress

-> Maybe String

Compressed, 0's and 1's, resulting string

Compresses a string by applying a table generator function and uses it to create a string of 0's and 1's.

compressToFile Source #

Arguments

:: (Num a, Ord a) 
=> (String -> Table a)

frequency or probability can be applied

-> String

String to compress

-> IO () 

Compresses a string to a file.

Calls the compress function on the input string and writes the binary code in a file.

The resulting files are: - 'out.bin' <- binary compressed file - 'decode.dat' <- contains the decoding table of out.bin

code Source #

Arguments

:: (Num a, Ord a) 
=> Table a

Input table

-> Encoding a

Resulting encoding

Given a Table encodes it by applying the Shannon-fano algorithm.

genCodeTable Source #

Arguments

:: (Num a, Ord a) 
=> Encoding a

Input encoding

-> CodeTable

Resulting code table

Generates a CodeTable

genDecodeTable Source #

Arguments

:: (Num a, Ord a) 
=> Encoding a

Input encoding

-> DecodeTable

Resulting decode table

Generates a DecodeTable

readDecodeTable Source #

Arguments

:: FilePath

File path for the decode table

-> IO (Maybe DecodeTable)

Decode table

Reads a DecodeTable from a file

decode Source #

Arguments

:: DecodeTable

Decoding table

-> String

Example "0110110111"

-> Maybe String

Resulting string

Decodes a String (made out of 0's and 1's) given a DecodeTable

decompressFromFile Source #

Arguments

:: FilePath

File holding the decoding table info

-> FilePath

File holding the compressed binary

-> String

Resulting file to output.

-> IO () 

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

If the resulting output file is empty ("") the default name is "result.dat"