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

Moduleregex-1.1.0.2Haskell2010

Text.RE.Tools.Lex

  • 1 type
  • 1 class
  • 4 values
  • Packageregex-1.1.0.2
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceLex.lhs

Find

2 declarations

The Lex toolkit uses REs to identify tokens in a file, returning a list of tokens.

See the Regex Tools tutorial at http://re-tutorial-tools.regex.uk

valuealex :: IsRegex re s => [(re, Match s -> Maybe t)] -> t -> s -> [t]
#

a simple regex-based scanner interpreter for prototyping scanners

valuealex'
  1. :: Replace s
  2. => re -> s -> Match s
  3. -> [(re, Match s -> Maybe t)]
  4. -> t
  5. -> s
  6. -> [t]
#

a higher order version of alex parameterised over the matchOnce function

IsRegex

4 declarations
classclass Replace s => IsRegex re s where
#

the IsRegex class allows polymorhic tools to be written that will work with a variety of regex back ends and text types

Methods

Instances6IsRegex
datadata SearchReplace re s
#

contains a compiled RE and replacement template

Constructors

  • SearchReplace
    • getSearch :: !re

      the RE to match a string to replace

    • getTemplate :: !s

      the replacement template with ${cap} used to identify a capture (by number or name if one was given) and $$ being used to escape a single $

Instances2Functor, Show
valuesearchReplaceAll :: IsRegex re s => SearchReplace re s -> s -> s
#

search and replace all matches in the argument text; e.g., this function will convert every YYYY-MM-DD format date in its argument text into a DD/MM/YYYY date:

searchReplaceAll [ed|${y}([0-9]{4})-0*${m}([0-9]{2})-0*${d}([0-9]{2})///${d}/${m}/${y}|]
valuesearchReplaceFirst :: IsRegex re s => SearchReplace re s -> s -> s
#

search and replace the first occurrence only (if any) in the input text e.g., to prefix the first string of four hex digits in the imput text, if any, with 0x:

searchReplaceFirst [ed|[0-9A-Fa-f]{4}///0x$0|]

Replace

0 declarations