-- 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.4
-- |
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
Suffix :: Int -> Int -> Seq Char -> Suffix
[suffixindex] :: Suffix -> Int
[suffixstartpos] :: Suffix -> Int
[suffix] :: Suffix -> Seq Char
-- | The SuffixArray data type. Uses sequence internally.
type SuffixArray = Seq Suffix
-- | The BWT data type. Uses sequence internally.
type BWT = Seq Char
-- | 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 -> Seq Char -> BWT
-- | Computes the corresponding SuffixArray of a given string.
-- Please see suffix array for more information.
createSuffixArray :: Seq Char -> SuffixArray
-- | 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 Char
-- | Abstract data type representing a BWTSeq in the (strict) ST monad.
type STBWTSeq s a = STRef s (BWTSeq Char)
-- | State function to push BWTString data into stack.
pushSTBWTSeq :: STBWTSeq s Char -> Char -> ST s ()
-- | State function to create empty STBWTString type.
emptySTBWTSeq :: ST s (STBWTSeq s Char)
-- | 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 (Char, Int) -> ST s (BWTSeq Char)
-- | Easy way to grab the first two elements of a sequence.
grabHeadChunks :: Seq (Seq Char) -> (Seq Char, Seq Char)
-- | 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
instance GHC.Classes.Ord Data.BWT.Internal.Suffix
instance GHC.Classes.Eq Data.BWT.Internal.Suffix
instance GHC.Read.Read Data.BWT.Internal.Suffix
instance GHC.Show.Show Data.BWT.Internal.Suffix
-- | 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.
--
-- 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.
--
-- Works with alphanumeric characters (A-Za-z0-9), as well as special
-- characters `~?!@#%^&*()_+<>';:[]{}/|"-., Does NOT
-- work with an input containing the $ character.
--
-- Appends the $ character to the input automatically.
toBWT :: String -> BWT
-- | 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 $ character.
fromBWT :: BWT -> String