regex-0.11.1.0: Toolkit for regex-base

Safe HaskellNone
LanguageHaskell2010

Text.RE.Tools.Edit

Contents

Synopsis

Editing

data Edits m re s Source #

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

Constructors

Select ![Edit m re s] 
Pipe ![Edit m re s] 

data Edit m re s Source #

each Edit action specifies how the match should be processed

Constructors

Template !(SearchReplace re s) 
Function !re REContext !(LineNo -> Match s -> RELocation -> Capture s -> m (Maybe s)) 
LineEdit !re !(LineNo -> Matches s -> m (LineEdit s)) 

data SearchReplace re s Source #

contains a compiled RE and replacement template

Constructors

SearchReplace 

Fields

Instances

Functor (SearchReplace re) Source # 

Methods

fmap :: (a -> b) -> SearchReplace re a -> SearchReplace re b #

(<$) :: a -> SearchReplace re b -> SearchReplace re a #

(Show s, Show re) => Show (SearchReplace re s) Source # 

Methods

showsPrec :: Int -> SearchReplace re s -> ShowS #

show :: SearchReplace re s -> String #

showList :: [SearchReplace re s] -> ShowS #

data LineEdit s Source #

a LineEdit is the most general action thar can be performed on a line and is the only means of deleting a line

Constructors

NoEdit 
ReplaceWith !s 
Delete 

Instances

Functor LineEdit Source # 

Methods

fmap :: (a -> b) -> LineEdit a -> LineEdit b #

(<$) :: a -> LineEdit b -> LineEdit a #

Show s => Show (LineEdit s) Source # 

Methods

showsPrec :: Int -> LineEdit s -> ShowS #

show :: LineEdit s -> String #

showList :: [LineEdit s] -> ShowS #

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 -> Edit m re 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

newtype LineNo Source #

our line numbers are of the proper zero-based kind

Constructors

ZeroBasedLineNo 

firstLine :: LineNo Source #

the first line in a file

getLineNo :: LineNo -> Int Source #

extract a conventional 1-based line number

lineNo :: Int -> LineNo Source #

inject a conventional 1-based line number

Text.RE

module Text.RE