alfred-margaret-1.1.1.0: Fast Aho-Corasick string searching

Safe HaskellNone
LanguageHaskell2010

Data.Text.AhoCorasick.Replacer

Contents

Description

Implements sequential string replacements based on the Aho-Corasick algorithm.

Synopsis

State machine

data Replacer Source #

A state machine used for efficient replacements with many different needles.

Instances
Eq Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Show Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Generic Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Associated Types

type Rep Replacer :: Type -> Type #

Methods

from :: Replacer -> Rep Replacer x #

to :: Rep Replacer x -> Replacer #

Hashable Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Methods

hashWithSalt :: Int -> Replacer -> Int #

hash :: Replacer -> Int #

ToJSON Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

FromJSON Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

NFData Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Methods

rnf :: Replacer -> () #

type Rep Replacer Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

type Rep Replacer = D1 (MetaData "Replacer" "Data.Text.AhoCorasick.Replacer" "alfred-margaret-1.1.1.0-C7p4DoDIXY7azqNtjX433" False) (C1 (MetaCons "Replacer" PrefixI True) (S1 (MetaSel (Just "replacerCaseSensitivity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CaseSensitivity) :*: S1 (MetaSel (Just "replacerSearcher") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Searcher Payload))))

build :: CaseSensitivity -> [(Needle, Replacement)] -> Replacer Source #

Build an Aho-Corasick automaton that can be used for performing fast sequential replaces.

Case-insensitive matching performs per-letter language-agnostic case folding. Therefore, it will work in most cases, but not in languages where case folding depends on the context of the character in question.

We need to revisit this algorithm when we want to implement full Unicode support.

compose :: Replacer -> Replacer -> Maybe Replacer Source #

Return the composition replacer2 after replacer1, if they have the same case sensitivity. If the case sensitivity differs, Nothing is returned.

type Needle = Text Source #

Descriptive type alias for strings to search for.

type Replacement = Text Source #

Descriptive type alias for replacements.

data Payload Source #

Instances
Eq Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Methods

(==) :: Payload -> Payload -> Bool #

(/=) :: Payload -> Payload -> Bool #

Show Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Generic Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Associated Types

type Rep Payload :: Type -> Type #

Methods

from :: Payload -> Rep Payload x #

to :: Rep Payload x -> Payload #

Hashable Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Methods

hashWithSalt :: Int -> Payload -> Int #

hash :: Payload -> Int #

ToJSON Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

FromJSON Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

NFData Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer

Methods

rnf :: Payload -> () #

type Rep Payload Source # 
Instance details

Defined in Data.Text.AhoCorasick.Replacer