Copyright | (c) Matthew Mosior 2022 |
---|---|
License | BSD-style |
Maintainer | mattm.github@gmail.com |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 Move-to-front transform (MTF)
and the Inverse MTF implementations, namely seqToMTFB
, seqToMTFT
, seqFromMTFB
, and seqFromMTFT
.
The MTF implementations rely heavily upon Seq
provided by the containers,
STRef
and associated functions in the stref library,
and runST
in the Control.Monad.ST library.
Synopsis
- newtype MTFB = MTFB (Seq Int, Seq (Maybe ByteString))
- newtype MTFT = MTFT (Seq Int, Seq (Maybe Text))
- nubSeq' :: Ord a => Seq (Maybe a) -> Seq (Maybe a)
- type PBMTFSeqB = Seq (Maybe ByteString)
- type MTFLSSeqB = (Seq Int, Seq (Maybe ByteString))
- type STMTFLSSeqB s a = STRef s MTFLSSeqB
- initializeSTMTFLSSeqB :: STMTFLSSeqB s (Seq Int, Seq (Maybe ByteString)) -> Seq (Maybe ByteString) -> ST s ()
- updateSTMTFLSSeqB :: STMTFLSSeqB s (Seq Int, Seq (Maybe ByteString)) -> Int -> ST s ()
- emptySTMTFLSSeqB :: ST s (STMTFLSSeqB s a)
- type STMTFILB s a = STRef s (Seq (Maybe ByteString))
- loadSTMTFILB :: STMTFILB s (Maybe ByteString) -> Seq (Maybe ByteString) -> ST s ()
- emptySTMTFILB :: ST s (STMTFILB s a)
- type STMTFCounterB s a = STRef s Int
- updateSTMTFCounterB :: STMTFCounterB s Int -> Int -> ST s ()
- emptySTMTFCounterB :: ST s (STMTFCounterB s Int)
- seqToMTFB :: PBMTFSeqB -> ST s MTFLSSeqB
- type PTMTFSeqT = Seq (Maybe Text)
- type MTFLSSeqT = (Seq Int, Seq (Maybe Text))
- type STMTFLSSeqT s a = STRef s MTFLSSeqT
- initializeSTMTFLSSeqT :: STMTFLSSeqT s (Seq Int, Seq (Maybe Text)) -> Seq (Maybe Text) -> ST s ()
- updateSTMTFLSSeqT :: STMTFLSSeqT s (Seq Int, Seq (Maybe Text)) -> Int -> ST s ()
- emptySTMTFLSSeqT :: ST s (STMTFLSSeqT s a)
- type STMTFILT s a = STRef s (Seq (Maybe Text))
- loadSTMTFILT :: STMTFILT s (Maybe Text) -> Seq (Maybe Text) -> ST s ()
- emptySTMTFILT :: ST s (STMTFILT s a)
- type STMTFCounterT s a = STRef s Int
- updateSTMTFCounterT :: STMTFCounterT s Int -> Int -> ST s ()
- emptySTMTFCounterT :: ST s (STMTFCounterT s Int)
- seqToMTFT :: PTMTFSeqT -> ST s MTFLSSeqT
- type FMTFSeqB = Seq (Maybe ByteString)
- type FSTMTFSeqB s a = STRef s FMTFSeqB
- updateFSTMTFSeqB :: FSTMTFSeqB s (Maybe ByteString) -> Maybe ByteString -> ST s ()
- emptyFSTMTFSeqB :: ST s (FSTMTFSeqB s a)
- type FSTMTFILB s a = STRef s (Seq (Maybe ByteString))
- loadFSTMTFILB :: FSTMTFILB s (Maybe ByteString) -> Seq (Maybe ByteString) -> ST s ()
- updateFSTMTFILB :: FSTMTFILB s (Maybe ByteString) -> Int -> ST s ()
- emptyFSTMTFILB :: ST s (FSTMTFILB s a)
- seqFromMTFB :: MTFB -> ST s FMTFSeqB
- type FMTFSeqT = Seq (Maybe Text)
- type FSTMTFSeqT s a = STRef s FMTFSeqT
- updateFSTMTFSeqT :: FSTMTFSeqT s (Maybe Text) -> Maybe Text -> ST s ()
- emptyFSTMTFSeqT :: ST s (FSTMTFSeqT s a)
- type FSTMTFILT s a = STRef s (Seq (Maybe Text))
- loadFSTMTFILT :: FSTMTFILT s (Maybe Text) -> Seq (Maybe Text) -> ST s ()
- updateFSTMTFILT :: FSTMTFILT s (Maybe Text) -> Int -> ST s ()
- emptyFSTMTFILT :: ST s (FSTMTFILT s a)
- seqFromMTFT :: MTFT -> ST s FMTFSeqT
Base MTF types
Basic MTF (ByteString
) data type.
Basic MTF (Text
) data type.
Auxiliary functions
nubSeq' :: Ord a => Seq (Maybe a) -> Seq (Maybe a) Source #
Useful to acquire the unique elements
that make up a Seq
.
Credit to @DavidFletcher.
See this stackoverflow post.
To MTF (ByteString) functions
type STMTFLSSeqB s a = STRef s MTFLSSeqB Source #
Abstract data type representing a MTFLSSeqB
in the (strict) ST monad.
initializeSTMTFLSSeqB :: STMTFLSSeqB s (Seq Int, Seq (Maybe ByteString)) -> Seq (Maybe ByteString) -> ST s () Source #
Abstract data type to initialize a STMTFLSSeqB
using the initial list.
updateSTMTFLSSeqB :: STMTFLSSeqB s (Seq Int, Seq (Maybe ByteString)) -> Int -> ST s () Source #
State function to update MTFLSSeqB
with each step of the MTF.
emptySTMTFLSSeqB :: ST s (STMTFLSSeqB s a) Source #
State function to create empty STMTFLSSeqB
type.
type STMTFILB s a = STRef s (Seq (Maybe ByteString)) Source #
Abstract STMTFILB
and associated state type.
loadSTMTFILB :: STMTFILB s (Maybe ByteString) -> Seq (Maybe ByteString) -> ST s () Source #
State function to load list into STMTFILB
.
type STMTFCounterB s a = STRef s Int Source #
Abstract STMTFCounterB
and associated state type.
updateSTMTFCounterB :: STMTFCounterB s Int -> Int -> ST s () Source #
State function to update STMTFCounterB
.
emptySTMTFCounterB :: ST s (STMTFCounterB s Int) Source #
State function to create empty STMTFCounterB
type.
To MTF (Text) functions
type STMTFLSSeqT s a = STRef s MTFLSSeqT Source #
Abstract data type representing a MTFLSSeqT
in the (strict) ST monad.
initializeSTMTFLSSeqT :: STMTFLSSeqT s (Seq Int, Seq (Maybe Text)) -> Seq (Maybe Text) -> ST s () Source #
Abstract data type to initialize a STMTFLSSeqT
using the initial list.
updateSTMTFLSSeqT :: STMTFLSSeqT s (Seq Int, Seq (Maybe Text)) -> Int -> ST s () Source #
State function to update STMTFLSSeqT
with each step of the MTF.
emptySTMTFLSSeqT :: ST s (STMTFLSSeqT s a) Source #
State function to create empty STMTFLSSeqT
type.
loadSTMTFILT :: STMTFILT s (Maybe Text) -> Seq (Maybe Text) -> ST s () Source #
State function to load list into STMTFILT
.
type STMTFCounterT s a = STRef s Int Source #
Abstract STMTFCounterT
and associated state type.
updateSTMTFCounterT :: STMTFCounterT s Int -> Int -> ST s () Source #
State function to update STMTFCounterT
.
emptySTMTFCounterT :: ST s (STMTFCounterT s Int) Source #
State function to create empty STMTFCounterT
type.
From MTF (ByteString) functions
type FSTMTFSeqB s a = STRef s FMTFSeqB Source #
Abstract data type representing a FMTFSeqB
in the (strict) ST monad.
updateFSTMTFSeqB :: FSTMTFSeqB s (Maybe ByteString) -> Maybe ByteString -> ST s () Source #
State function to update FSTMTFSeqB
with each step of the inverse MTF.
emptyFSTMTFSeqB :: ST s (FSTMTFSeqB s a) Source #
State function to create empty FSTMTFSeqB
type.
type FSTMTFILB s a = STRef s (Seq (Maybe ByteString)) Source #
Abstract FSTMTFILB
and associated state type.
loadFSTMTFILB :: FSTMTFILB s (Maybe ByteString) -> Seq (Maybe ByteString) -> ST s () Source #
State function to load list into FSTMTFILB
.
updateFSTMTFILB :: FSTMTFILB s (Maybe ByteString) -> Int -> ST s () Source #
State function to update FSTMTFILB
.
From MTF (Text) functions
type FSTMTFSeqT s a = STRef s FMTFSeqT Source #
Abstract data type representing a FMTFSeqT
in the (strict) ST monad.
updateFSTMTFSeqT :: FSTMTFSeqT s (Maybe Text) -> Maybe Text -> ST s () Source #
State function to update FSTMTFSeqT
with each step of the inverse MTF.
emptyFSTMTFSeqT :: ST s (FSTMTFSeqT s a) Source #
State function to create empty FSTMTFSeqT
type.
type FSTMTFILT s a = STRef s (Seq (Maybe Text)) Source #
Abstract FSTMTFILT
and associated state type.
loadFSTMTFILT :: FSTMTFILT s (Maybe Text) -> Seq (Maybe Text) -> ST s () Source #
State function to load list into FSTMTFILT
.