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

Safe HaskellNone
LanguageHaskell2010

Retrie.Run

Synopsis

Documentation

runScript :: (Options -> IO (Retrie ())) -> IO () Source #

Define a custom refactoring script. A script is an IO action that defines a Retrie computation. The IO action is run once, and the resulting Retrie computation is run once for each target file. Typically, rewrite parsing/construction is done in the IO action, so it is performed only once. Example:

module Main where

main :: IO ()
main = runScript $ \opts -> do
  rr <- parseRewrites opts ["forall f g xs. map f (map g xs) = map (f . g) xs"]
  return $ apply rr

To run the script, compile the program and execute it.

runScriptWithModifiedOptions :: (Options -> IO (Options, Retrie ())) -> IO () Source #

Define a custom refactoring script and run it with modified options. This is the same as runScript, but the returned Options will be used during rewriting.

execute :: Options -> Retrie () -> IO () Source #

Implements retrie's iteration and execution modes.

run Source #

Arguments

:: Monoid b 
=> (FilePath -> WriteFn a b)

write action when a file changes, unchanged files result in mempty

-> (IO b -> IO c)

wrap per-file rewrite action

-> Options 
-> Retrie a 
-> IO [c] 

Primitive means of running a Retrie computation.

type WriteFn a b = [Replacement] -> String -> a -> IO b Source #

Callback function to actually write the resulting file back out. Is given list of changed spans, module contents, and user-defined data.

writeCountLines :: FilePath -> WriteFn a (Sum Int) Source #

Write action which counts changed lines using diff

writeDiff :: Options -> FilePath -> WriteFn a (Sum Int) Source #

Print the lines before replacement and after replacement.

writeSearch :: Options -> FilePath -> WriteFn a () Source #

Print lines that match the query and highligh the matched string.

writeExtract :: Options -> FilePath -> WriteFn a () Source #

Print only replacement.