text-compression-0.1.0.6: A text compression library.
Copyright(c) Matthew Mosior 2022
LicenseBSD-style
Maintainermattm.github@gmail.com
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.BWT

Description

Burrows-Wheeler Transform (BWT)

The two functions that most users will utilize are toBWT and fromBWT. There are auxilary function(s) inside of Data.BWT.Internal.

The helper functions for ByteString, bytestringToBWT and bytestringFromBWT and Text, textToBWT and textFromBWT should help for common use cases.

Data.BWT.Internal also has the function createBWTMatrix, which can be useful as well, although not used by either toBWT or fromBWT.

Synopsis

Documentation

toBWT :: Ord a => [a] -> BWT a Source #

Takes a String and returns the Burrows-Wheeler Transform (BWT). Implemented via a SuffixArray.

bytestringToBWT :: ByteString -> BWT Word8 Source #

Helper function for converting a ByteString to a BWT Word8.

newtype TextBWT Source #

Constructors

TextBWT (BWT Word8) 

textToBWT :: Text -> TextBWT Source #

Helper function for converting Text to a TextBWT.

fromBWT :: Ord a => BWT a -> [a] Source #

Takes a BWT data type (please see Data.BWT.Internal) and inverts it back to the original string.

This function utilizes the state monad (strict) in order to implement the Magic Inverse BWT algorithm by backtracking indices starting with the (Nothing,_) entry.

bytestringFromBWT :: BWT Word8 -> ByteString Source #

Helper function for converting a BWT Word8 to a ByteString.

textFromBWT :: TextBWT -> Text Source #

Helper function for converting TextBWT to a Text