Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data DecodeTableError = DecodeTableError
- frequency :: Input -> Table Int
- probability :: Input -> Table Float
- genCodeTable :: Input -> Table ByteString
- compress :: Input -> ByteString
- decompress :: ByteString -> Table ByteString -> Maybe Input
- compressToFile :: Handle -> String -> IO ()
- decompressFromFile :: Handle -> Table ByteString -> String -> IO (Either DecodeTableError ())
Documentation
data DecodeTableError Source #
Decode table error can happen when the wrong code table is provided.
Instances
Eq DecodeTableError Source # | |
Defined in Codec.Compression.ShannonFano (==) :: DecodeTableError -> DecodeTableError -> Bool # (/=) :: DecodeTableError -> DecodeTableError -> Bool # | |
Show DecodeTableError Source # | |
Defined in Codec.Compression.ShannonFano showsPrec :: Int -> DecodeTableError -> ShowS # show :: DecodeTableError -> String # showList :: [DecodeTableError] -> ShowS # |
Gives the frequency table of all characters in a string.
Gives the probability table of all characters in a string.
:: Input | Input string |
-> Table ByteString | Resulting code table |
Generates a DecodeTable
:: Input | Input string |
-> ByteString | Result compressed |
Given a 'Table ByteString' compresses it by applying the Shannon-fano algorithm.
:: 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.
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
:: 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.