| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.RE.Tools.Grep
- grep :: IsRegex re ByteString => Verbosity -> re -> FilePath -> IO ()
- data Line = Line {}
- grepLines :: IsRegex re ByteString => re -> FilePath -> IO [Line]
- type GrepScript re s t = [(re, LineNo -> Matches s -> Maybe t)]
- grepScript :: IsRegex re s => GrepScript re s t -> [s] -> [t]
- report :: Verbosity -> [Line] -> String
- data Verbosity
- linesMatched :: Verbosity -> [Line] -> [Line]
- class Replace s => IsRegex re s where
- newtype LineNo = ZeroBasedLineNo {}
- firstLine :: LineNo
- getLineNo :: LineNo -> Int
- lineNo :: Int -> LineNo
- module Text.RE
Documentation
grep :: IsRegex re ByteString => Verbosity -> re -> FilePath -> IO () Source #
operates a bit like classic grep printing out the lines matched
Constructors
| Line | |
Fields
| |
grepLines :: IsRegex re ByteString => re -> FilePath -> IO [Line] Source #
returns a Line for each line in the file enumerating all of the
matches for that line.
type GrepScript re s t = [(re, LineNo -> Matches s -> Maybe t)] Source #
a GrepScript lists RE-action associations, with the first RE to match a line selecting the action to be executed on each line in the file
grepScript :: IsRegex re s => GrepScript re s t -> [s] -> [t] Source #
given a list of lines, apply the GrepScript to each line of the file
specifies whether to return the linss matched or missed
Constructors
| LinesMatched | |
| LinesNotMatched |
linesMatched :: Verbosity -> [Line] -> [Line] Source #
given a velocity flag filter out either the lines matched or not
matched
IsRegex
class Replace s => IsRegex re s where Source #
the IsRegex class allows tools to be written that will work with
regex back end text type supported by the back end
Minimal complete definition
matchOnce, matchMany, makeRegexWith, makeSearchReplaceWith, regexSource
Methods
matchOnce :: re -> s -> Match s Source #
finding the first match
matchMany :: re -> s -> Matches s Source #
finding all matches
makeRegex :: (Functor m, Monad m) => s -> m re Source #
compiling an RE, failing if the RE is not well formed
makeRegexWith :: (Functor m, Monad m) => SimpleREOptions -> s -> m re Source #
comiling an RE, specifying the SimpleREOptions
makeSearchReplace :: (Functor m, Monad m, IsRegex re s) => s -> s -> m (SearchReplace re s) Source #
compiling a SearchReplace template from the RE text and the template Text, failing if they are not well formed
makeSearchReplaceWith :: (Functor m, Monad m, IsRegex re s) => SimpleREOptions -> s -> s -> m (SearchReplace re s) Source #
compiling a SearchReplace template specifing the SimpleREOptions for the RE
makeEscaped :: (Functor m, Monad m) => (s -> s) -> s -> m re Source #
incorporate an escaped string into a compiled RE with the default options
makeEscapedWith :: (Functor m, Monad m) => SimpleREOptions -> (s -> s) -> s -> m re Source #
incorporate an escaped string into a compiled RE with the specified SimpleREOptions
regexSource :: re -> s Source #
extract the text of the RE from the RE
LineNo
our line numbers are of the proper zero-based kind
Constructors
| ZeroBasedLineNo | |
Fields | |
Text.RE
module Text.RE