Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data REContext
- data RELocation = RELocation {}
- isTopLocation :: RELocation -> Bool
- replaceAll :: Replace a => a -> Matches a -> a
- replaceAllCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Matches a -> m a
- replace :: Replace a => a -> Match a -> a
- replaceCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a
- replaceCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a
- replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Match a -> m a
- expandMacros :: (r -> String) -> Macros r -> String -> String
- expandMacros' :: (MacroID -> Maybe String) -> String -> String
- templateCaptures :: (Replace a, RegexContext Regex a (Matches a), RegexMaker Regex CompOption ExecOption String) => (a -> String) -> a -> [CaptureID]
- class (Show a, Eq a, Ord a, Extract a, Monoid a) => Replace a where
- data ReplaceMethods a = ReplaceMethods {
- methodLength :: a -> Int
- methodSubst :: (a -> a) -> Capture a -> a
- replaceMethods :: Replace a => ReplaceMethods a
REContext and RELocation
REContext
specifies which contexts the substitutions should be applied
data RELocation Source #
the RELocation
information passed into the substitution function
specifies which sub-expression is being substituted
RELocation | |
|
isTopLocation :: RELocation -> Bool Source #
True iff the location references a complete match (i.e., not a bracketed capture)
replaceAll
replaceAll :: Replace a => a -> Matches a -> a Source #
replace all with a template, $0 for whole text, $1 for first capture, etc.
replaceAllCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a Source #
substitutes using a function that takes the full Match context and returns the same replacement text as the _phi_phi context.
replaceAllCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a Source #
replaceAllCaptures_ is like like replaceAllCaptures but takes the Replace methods through the ReplaceMethods argument
replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Matches a -> m a Source #
replaceAllCapturesM is just a monadically generalised version of replaceAllCaptures_
replace
replaceCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a Source #
substitutes using a function that takes the full Match context and returns the same replacement text as the _phi_phi context.
replaceCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a Source #
replaceCaptures_ is like replaceCaptures but takes the Replace methods through the ReplaceMethods argument
replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Match a -> m a Source #
replaceCapturesM is just a monadically generalised version of replaceCaptures_
expandMacros
expandMacros :: (r -> String) -> Macros r -> String -> String Source #
expand all of the @{..} macros in the RE in the argument String according to the Macros argument, preprocessing the RE String according to the Mode argument (used internally)
expandMacros' :: (MacroID -> Maybe String) -> String -> String Source #
expand the @{..} macos in the argument string using the given function
templateCaptures
templateCaptures :: (Replace a, RegexContext Regex a (Matches a), RegexMaker Regex CompOption ExecOption String) => (a -> String) -> a -> [CaptureID] Source #
list all of the CaptureID references in the replace template in the second argument
Replace and ReplaceMethods
class (Show a, Eq a, Ord a, Extract a, Monoid a) => Replace a where Source #
Replace provides the missing needed to replace the matched
text in a Replace a => Match a
.
length function for a
inject String into a
unpackR :: a -> String Source #
project a onto a String
textifyR :: a -> Text Source #
inject into Text
detextifyR :: Text -> a Source #
project Text onto a
split into lines
concatenate a list of lines
appendNewlineR :: a -> a Source #
append a newline
substR :: (a -> a) -> Capture a -> a Source #
apply a substitution function to a Capture
parseTemplateR :: a -> Match a -> RELocation -> Capture a -> Maybe a Source #
convert a template containing $0, $1, etc., in the first
argument, into a phi
replacement function for use with
replaceAllCaptures and replaceCaptures
data ReplaceMethods a Source #
a selction of the Replace methods can be encapsulated with ReplaceMethods for the higher-order replacement functions
ReplaceMethods | |
|
replaceMethods :: Replace a => ReplaceMethods a Source #
replaceMethods encapsulates ReplaceMethods a from a Replace a context