HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulefuzzy-0.1.1.0Haskell2010

Text.Fuzzy

Fuzzy string search in Haskell. Uses TextualMonoid to be able to run on different types of strings.

  • 1 type
  • 4 values
  • Packagefuzzy-0.1.1.0
  • Exports5
  • LanguageHaskell2010
  • LicenceMIT
  • SourceFuzzy.hs
valuematch
  1. :: TextualMonoid s
  2. => s

    Pattern.

  3. -> t

    The value containing the text to search in.

  4. -> s

    The text to add before each match.

  5. -> s

    The text to add after each match.

  6. -> (t -> s)

    The function to extract the text from the container.

  7. -> Bool

    Case sensitivity.

  8. -> Maybe (Fuzzy t s)

    The original value, rendered string and score.

#

Returns the rendered output and the matching score for a pattern and a text. Two examples are given below:

Example1 expression
match "fnt" "infinite" "" "" id TrueJust ("infinite",3)
Example1 expression
match "hsk" ("Haskell",1995) "<" ">" fst FalseJust ("<H>a<s><k>ell",5)
valuefilter
  1. :: TextualMonoid s
  2. => s

    Pattern.

  3. -> [t]

    The list of values containing the text to search in.

  4. -> s

    The text to add before each match.

  5. -> s

    The text to add after each match.

  6. -> (t -> s)

    The function to extract the text from the container.

  7. -> Bool

    Case sensitivity.

  8. -> [Fuzzy t s]

    The list of results, sorted, highest score first.

#

The function to filter a list of values by fuzzy search on the text extracted from them.

Example1 expression
filter "ML" [("Standard ML", 1990),("OCaml",1996),("Scala",2003)] "<" ">" fst False[Fuzzy {original = ("Standard ML",1990), rendered = "Standard <M><L>", score = 4},Fuzzy {original = ("OCaml",1996), rendered = "OCa<m><l>", score = 4}]
valuesimpleFilter
  1. :: TextualMonoid s
  2. => s

    Pattern to look for.

  3. -> [s]

    List of texts to check.

  4. -> [s]

    The ones that match.

#

Return all elements of the list that have a fuzzy match against the pattern. Runs with default settings where nothing is added around the matches, as case insensitive.

Example1 expression
simpleFilter "vm" ["vim", "emacs", "virtual machine"]["vim","virtual machine"]
valuetest :: TextualMonoid s => s -> s -> Bool
#

Returns false if the pattern and the text do not match at all. Returns true otherwise.

Example1 expression
test "brd" "bread"True