-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A text compression library. -- -- This package contains efficient implementations of the Burrows-Wheeler -- Transform (BWT) and Inverse BWT algorithms. @package text-compression @version 0.1.0.6 -- |

WARNING

-- -- This module is considered internal. -- -- The Package Versioning Policy does not apply. -- -- The contents of this module may change in any way whatsoever -- and without any warning between minor versions of this package. -- -- Authors importing this library are expected to track development -- closely. -- -- All credit goes to the author(s)/maintainer(s) of the -- containers library for the above warning text. -- --

Description

-- -- Various data structures and custom data types to describe the -- Burrows-Wheeler Transform (BWT) and the Inverse BWT. -- -- The implementation of the BWT relies upon sequence provided by the -- containers. -- -- The internal BWTMatrix data type relies upon the massiv -- package. module Data.BWT.Internal -- | Basic suffix data type. Used to describe the core data inside of the -- SuffixArray data type. data Suffix a Suffix :: Int -> Int -> Maybe (Seq a) -> Suffix a [suffixindex] :: Suffix a -> Int [suffixstartpos] :: Suffix a -> Int [suffix] :: Suffix a -> Maybe (Seq a) -- | The SuffixArray data type. Uses sequence internally. type SuffixArray a = Seq (Suffix a) -- | The BWT data type. Uses sequence internally. type BWT a = Seq (Maybe a) -- | The BWTMatrix data type. Uses a massiv array internally. type BWTMatrix = Array BN Ix1 String -- | Computes the Burrows-Wheeler Transform (BWT) using the suffix array -- and the original string (represented as a sequence for performance). saToBWT :: SuffixArray a -> Seq a -> BWT a -- | Computes the corresponding SuffixArray of a given string. -- Please see suffix array for more information. createSuffixArray :: Ord a => Seq a -> SuffixArray a -- | Hierarchical sorting scheme that compares fst first then snd. -- Necessary for the setting up the BWT in order to correctly invert it -- using the Magic algorithm. sortTB :: (Ord a1, Ord a2) => (a1, a2) -> (a1, a2) -> Ordering -- | Abstract BWTSeq type utilizing a sequence. type BWTSeq a = Seq a -- | Abstract data type representing a BWTSeq in the (strict) ST monad. type STBWTSeq s a = STRef s (BWTSeq a) -- | State function to push BWTString data into stack. pushSTBWTSeq :: STBWTSeq s a -> a -> ST s () -- | State function to create empty STBWTString type. emptySTBWTSeq :: ST s (STBWTSeq s a) -- | Abstract BWTCounter and associated state type. type STBWTCounter s a = STRef s Int -- | State function to update BWTCounter. updateSTBWTCounter :: STBWTCounter s Int -> Int -> ST s () -- | State function to create empty STBWTCounter type. emptySTBWTCounter :: ST s (STBWTCounter s Int) -- | Magic Inverse BWT function. magicInverseBWT :: Seq (Maybe a, Int) -> ST s (BWTSeq a) -- | Simple yet efficient implementation of converting a given string into -- a BWT Matrix (the BWTMatrix type is a massiv array). createBWTMatrix :: String -> BWTMatrix instance GHC.Generics.Generic (Data.BWT.Internal.Suffix a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.BWT.Internal.Suffix a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.BWT.Internal.Suffix a) instance GHC.Read.Read a => GHC.Read.Read (Data.BWT.Internal.Suffix a) instance GHC.Show.Show a => GHC.Show.Show (Data.BWT.Internal.Suffix a) -- |

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. module Data.BWT -- | Takes a String and returns the Burrows-Wheeler Transform (BWT). -- Implemented via a SuffixArray. toBWT :: Ord a => [a] -> BWT a -- | Helper function for converting a ByteString to a BWT -- Word8. bytestringToBWT :: ByteString -> BWT Word8 newtype TextBWT TextBWT :: BWT Word8 -> TextBWT -- | Helper function for converting Text to a TextBWT. textToBWT :: Text -> TextBWT -- | 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. fromBWT :: Ord a => BWT a -> [a] -- | Helper function for converting a BWT Word8 to a -- ByteString. bytestringFromBWT :: BWT Word8 -> ByteString -- | Helper function for converting TextBWT to a Text textFromBWT :: TextBWT -> Text