Descriptive type alias for strings to search for.
Modulealfred-margaret-2.1.1.1Haskell2010
Data.Text.AhoCorasick.Replacer
Implements sequential string replacements based on the Aho-Corasick algorithm.
- 4 types
- 7 values
- Packagealfred-margaret-2.1.1.1
- Exports11
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceReplacer.hs
State machine
11 declarationsConstructors
PayloadneedlePriority :: !PriorityneedleLengthBytes :: !CodeUnitIndexNumber of bytes is used for case sensitive matching
needleLengthCodePoints :: !IntFor case insensitive matches, the byte length does not necessarily match the needle byte length. Due to our simple case folding the number of codepoints _does_ match, so we put that in the payload. It's less efficient because we have to scan backwards through the text to obtain the length of a match.
needleReplacement :: !Replacement
Instances8Eq, Show, Generic, NFData, Hashable, FromJSON, …
Eq PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerShow PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerGeneric PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerNFData PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerHashable PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerFromJSON PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerToJSON PayloadDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.Replacertype Rep Payload = D1 ('MetaDataDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.Replacer"Payload"
"Data.Text.AhoCorasick.Replacer"
"alfred-margaret-2.1.1.1-ASFUiU1mFjDAljTyYzURM4"
'False) (C1 ('MetaCons"Payload"
'PrefixI 'True) ((S1 ('MetaSel ('Just"needlePriority"
) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Priority) :*: S1 ('MetaSel ('Just"needleLengthBytes"
) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 CodeUnitIndex)) :*: (S1 ('MetaSel ('Just"needleLengthCodePoints"
) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Int) :*: S1 ('MetaSel ('Just"needleReplacement"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Replacement))))
Descriptive type alias for replacements.
A state machine used for efficient replacements with many different needles.
Constructors
Instances8Eq, Show, Generic, NFData, Hashable, FromJSON, …
Eq ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerShow ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerGeneric ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerNFData ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerHashable ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerFromJSON ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.ReplacerToJSON ReplacerDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.Replacertype Rep Replacer = D1 ('MetaDataDefined in alfred-margaret-2.1.1.1 · Data.Text.AhoCorasick.Replacer"Replacer"
"Data.Text.AhoCorasick.Replacer"
"alfred-margaret-2.1.1.1-ASFUiU1mFjDAljTyYzURM4"
'False) (C1 ('MetaCons"Replacer"
'PrefixI 'True) (S1 ('MetaSel ('Just"replacerSearcher"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Searcher Payload))))
Build an Aho-Corasick automaton that can be used for performing fast sequential replaces.
Case-insensitive matching performs per-letter language-agnostic lower-casing. Therefore, it will work in most cases, but not in languages where lower-casing depends on the context of the character in question.
We need to revisit this algorithm when we want to implement full Unicode support.
Return the composition replacer2 after replacer1, if they have the same
case sensitivity. If the case sensitivity differs, Nothing is returned.
Modify the replacement of a replacer. It doesn't modify the needles.
Updates the case sensitivity of the replacer. Does not change the capitilization of the needles. The caller should be certain that if IgnoreCase is passed, the needles are already lower case.