Safe Haskell | None |
---|---|
Language | Haskell2010 |
- sed :: IsRegex re ByteString => Edits IO re ByteString -> FilePath -> FilePath -> IO ()
- sed' :: (IsRegex re a, Monad m, Functor m) => Edits m re a -> a -> m a
- grep :: IsRegex re ByteString => Verbosity -> re -> FilePath -> IO ()
- 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]
- linesMatched :: Verbosity -> [Line] -> [Line]
- alex :: IsRegex re s => [(re, Match s -> Maybe t)] -> t -> s -> [t]
- alex' :: Replace s => (re -> s -> Match s) -> [(re, Match s -> Maybe t)] -> t -> s -> [t]
- class Replace s => IsRegex re s where
- data Edits m re s
- data Edit m s
- data LineEdit s
- = NoEdit
- | ReplaceWith s
- | Delete
- applyEdits :: (IsRegex re s, Monad m, Functor m) => LineNo -> Edits m re s -> s -> m s
- applyEdit :: (IsRegex re s, Monad m, Functor m) => (s -> s) -> LineNo -> re -> Edit m s -> s -> m (Maybe s)
- applyLineEdit :: Monoid s => (s -> s) -> LineEdit s -> Maybe s
- newtype LineNo = ZeroBasedLineNo {}
- firstLine :: LineNo
- getLineNo :: LineNo -> Int
- lineNo :: Int -> LineNo
- module Text.RE
The Tools
Sed
sed :: IsRegex re ByteString => Edits IO re ByteString -> FilePath -> FilePath -> IO () Source #
read a file, apply an Edits
script to each line it and
write the file out again; "-" is used to indicate standard input
standard output as appropriate
sed' :: (IsRegex re a, Monad m, Functor m) => Edits m re a -> a -> m a Source #
apply an Edits
script to each line of the argument text
Grep
grep :: IsRegex re ByteString => Verbosity -> re -> FilePath -> IO () Source #
operates a bit like classic grep
printing out the lines matched
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
linesMatched :: Verbosity -> [Line] -> [Line] Source #
given a velocity
flag filter out either the lines matched or not
matched
Lex
alex :: IsRegex re s => [(re, Match s -> Maybe t)] -> t -> s -> [t] Source #
a simple regex-based scanner interpretter for prototyping scanners
alex' :: Replace s => (re -> s -> Match s) -> [(re, Match s -> Maybe t)] -> t -> s -> [t] Source #
a higher order version of alex
parameterised over the matchOnce
function
IsRegex
Edit
an Edits
script will, for each line in the file, either perform
the action selected by the first RE in the list, or perform all of the
actions on line, arranged as a pipeline
each Edit action specifies how the match should be processed
a LineEdit is the most general action thar can be performed on a line and is the only means of deleting a line
applyEdits :: (IsRegex re s, Monad m, Functor m) => LineNo -> Edits m re s -> s -> m s Source #
apply an Edit
script to a single line
applyEdit :: (IsRegex re s, Monad m, Functor m) => (s -> s) -> LineNo -> re -> Edit m s -> s -> m (Maybe s) Source #
apply a single edit action to a line, the function in the first argument
being used to add a new line onto the end of the line where appropriate;
the function returns Nothing
if no edit is to be performed on the line,
Just mempty
to delete the line
applyLineEdit :: Monoid s => (s -> s) -> LineEdit s -> Maybe s Source #
apply a LineEdit
to a line, using the function in the first
argument to append a new line to the result; Nothing should be
returned if no edit is to be performed, Just mempty
to
delete the line
LineNo
Text.RE
module Text.RE