HaRe-0.8.4.0: the Haskell Refactorer.

Safe HaskellNone
LanguageHaskell98

Language.Haskell.Refact.Utils.Utils

Contents

Synopsis

Managing the GHC / project environment

parseSourceFileGhc :: FilePath -> RefactGhc () Source #

Parse a single source file into a GHC session

The bits that do the work

runRefacSession Source #

Arguments

:: RefactSettings 
-> Options

ghc-mod options

-> RefactGhc [ApplyRefacResult]

The computation doing the refactoring. Normally created via applyRefac

-> IO [FilePath] 

Manage a whole refactor session. Initialise the monad, load the whole project if required, and then apply the individual refactorings, and write out the resulting files.

It is intended that this forms the umbrella function, in which applyRefac is called

applyRefac :: RefactGhc a -> RefacSource -> RefactGhc (ApplyRefacResult, a) Source #

Apply a refactoring (or part of a refactoring) to a single module

applyRefac' Source #

Arguments

:: Bool

Boolean that determines if the state should be cleared

-> RefactGhc a

The refactoring

-> RefacSource

where to get the module and toks

-> RefactGhc (ApplyRefacResult, a) 

refactDone :: [ApplyRefacResult] -> Bool Source #

Returns True if any of the results has its modified flag set

getModuleName :: ParsedSource -> Maybe (ModuleName, String) Source #

Extract the module name from the parsed source, if there is one

clientModsAndFiles :: ModulePath -> RefactGhc [TargetModule] Source #

Return the client modules and file names. The client modules of module, say m, are those modules which directly or indirectly import module m.

serverModsAndFiles :: GhcMonad m => ModuleName -> m [ModSummary] Source #

Return the server module and file names. The server modules of module, say m, are those modules which are directly or indirectly imported by module m. This can only be called in a live GHC session TODO: make sure this works with multiple targets. Is that needed?

runMultRefacSession :: RefactSettings -> Options -> [RefactGhc [ApplyRefacResult]] -> IO [FilePath] Source #

Like runRefacSession but instead takes an ordered list of RefactGhc computations and runs all of them threading the state through all of the computations

writeRefactoredFiles :: VerboseLevel -> [ApplyRefacResult] -> IO () Source #

Write refactored program source to files.

stripCallStack :: String -> String Source #

In GHC 8 an error has an attached callstack. This is not always what we want, so this function strips it