retrie-1.2.2: A powerful, easy-to-use codemodding tool for Haskell.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Retrie.Replace

Synopsis

- replace :: (Data a, MonadIO m) => Context -> a -> TransformT (WriterT Change m) a
- data Replacement = Replacement {
  - replLocation :: SrcSpan
  - replOriginal :: String
  - replReplacement :: String
  }
- data Change
  - = NoChange
  - | Change [Replacement] [AnnotatedImports]

# Documentation

replace :: (Data a, MonadIO m) => Context -> a -> TransformT (WriterT Change m) a #

Specializes `replaceImpl` to each of the AST types that retrie supports.

data Replacement #

Records a replacement made. In cases where we cannot use ghc-exactprint to print the resulting AST (e.g. CPP modules), we fall back on splicing strings. Can also be used by external tools (search, linters, etc).

Constructors

Replacement |

Fields

- replLocation :: SrcSpan
- replOriginal :: String
- replReplacement :: String

#### Instances

Instances details

Show Replacement # |
Instance details Defined in Retrie.Replace Methods showsPrec :: Int -> Replacement -> ShowS show :: Replacement -> String showList :: [Replacement] -> ShowS

data Change #

Used as the writer type during matching to indicate whether any change to the module should be made.

Constructors

NoChange |
Change [Replacement] [AnnotatedImports] |

#### Instances

Instances details

Monoid Change # |
Instance details Defined in Retrie.Replace Methods mempty :: Change mappend :: Change -> Change -> Change # mconcat :: [Change] -> Change
Semigroup Change # |
Instance details Defined in Retrie.Replace Methods (<>) :: Change -> Change -> Change # sconcat :: NonEmpty Change -> Change stimes :: Integral b => b -> Change -> Change