Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- runScript :: (Options -> IO (Retrie ())) -> IO ()
- runScriptWithModifiedOptions :: (Options -> IO (Options, Retrie ())) -> IO ()
- execute :: Options -> Retrie () -> IO ()
- run :: Monoid b => (FilePath -> WriteFn a b) -> (IO b -> IO c) -> Options -> Retrie a -> IO [c]
- type WriteFn a b = [Replacement] -> String -> a -> IO b
- writeCountLines :: FilePath -> WriteFn a (Sum Int)
- writeDiff :: Options -> FilePath -> WriteFn a (Sum Int)
- writeSearch :: Options -> FilePath -> WriteFn a ()
- writeExtract :: Options -> FilePath -> WriteFn a ()
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.
:: Monoid b | |
=> (FilePath -> WriteFn a b) | write action when a file changes, unchanged files result in |
-> (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.