Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- frequency :: String -> Table Int
- probability :: String -> Table Float
- compress :: (Num a, Ord a) => (String -> Table a) -> String -> Maybe String
- compressToFile :: (Num a, Ord a) => (String -> Table a) -> String -> IO ()
- code :: (Num a, Ord a) => Table a -> Encoding a
- genCodeTable :: (Num a, Ord a) => Encoding a -> CodeTable
- genDecodeTable :: (Num a, Ord a) => Encoding a -> DecodeTable
- readDecodeTable :: FilePath -> IO (Maybe DecodeTable)
- decode :: DecodeTable -> String -> Maybe String
- decompressFromFile :: FilePath -> FilePath -> String -> IO ()
Documentation
Gives the frequency table of all characters in a string.
Gives the probability table of all characters in a string.
:: (Num a, Ord a) | |
=> (String -> Table a) |
|
-> 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.
:: (Num a, Ord a) | |
=> (String -> Table a) |
|
-> 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
Given a Table
encodes it by applying the Shannon-fano
algorithm.
Generates a CodeTable
Generates a DecodeTable
Reads a DecodeTable
from a file
Decodes a String
(made out of 0's and 1's) given a DecodeTable