HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Modulealfred-margaret-2.1.1.1Haskell2010

Data.Text.AhoCorasick.Replacer

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

  • 4 types
  • 7 values

State machine

11 declarations
typetype Needle = Text
#

Descriptive type alias for strings to search for.

datadata Payload
#

Constructors

Instances8Eq, Show, Generic, NFData, Hashable, FromJSON, …
datadata Replacer
#

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

Instances8Eq, Show, Generic, NFData, Hashable, FromJSON, …

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.

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.