Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class (Extract a, Monoid a) => Replace a where
- data Replace_ a = Replace_ {}
- replace_ :: Replace a => Replace_ a
- data Phi a = Phi {
- _phi_context :: Context
- _phi_phi :: Location -> a -> a
- data Context
- data Location = Location {}
- isTopLocation :: Location -> Bool
- replace :: Replace a => Match a -> a -> a
- replaceAll :: Replace a => a -> Matches a -> a
- replaceAllCaptures :: Replace a => Phi a -> Matches a -> a
- replaceAllCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCapturesM :: (Extract a, Monad m) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a
- replaceCaptures :: Replace a => Phi a -> Match a -> a
- replaceCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- replaceCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- replaceCapturesM :: (Monad m, Extract a) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a
- expandMacros :: (r -> String) -> Mode -> Macros r -> String -> String
- expandMacros' :: (MacroID -> Maybe String) -> String -> String
Documentation
class (Extract a, Monoid a) => Replace a where Source
Replace provides the missing methods needed to replace the matched text; length_ is the minimum implementation
length function for a
inject String into a
project a onto a String
inject into Text
project Text onto a
appendNewline :: a -> a Source
append a newline
subst :: (a -> a) -> Capture a -> a Source
apply a substitution function to a Capture
parse_tpl :: a -> Match a -> Location -> 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'
a selction of the Replace methods can be encapsulated with Replace_ for the higher-order replacement functions
Phi
specifies the substitution function for procesing the substrings
captured by the regular expression.
Phi | |
|
Context
specifies which contexts the substitutions should be applied
the Location
information passed into the substitution function
specifies which sub-expression is being substituted
Location | |
|
isTopLocation :: Location -> Bool Source
True iff the location references a complete match (i.e., not a bracketed capture)
replace :: Replace a => Match a -> a -> a Source
replace with a template containing $0 for whole text, $1 for first capture, etc.
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 => Phi a -> Matches a -> a Source
substitutes the PHI substitutions through the Matches
replaceAllCaptures' :: Replace a => Context -> (Match a -> Location -> 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 => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a Source
replaceAllCaptures_ is like like replaceAllCaptures' but takes the Replace methods through the Replace_ argument
replaceAllCapturesM :: (Extract a, Monad m) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a Source
replaceAllCapturesM is just a monadically generalised version of replaceAllCaptures_
replaceCaptures :: Replace a => Phi a -> Match a -> a Source
substitutes the PHI substitutions through the Match
replaceCaptures' :: Replace a => Context -> (Match a -> Location -> 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 => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a Source
replaceCaptures_ is like replaceCaptures' but takes the Replace methods through the Replace_ argument
replaceCapturesM :: (Monad m, Extract a) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a Source
replaceCapturesM is just a monadically generalised version of replaceCaptures_