apply-refact-0.9.2.0: Perform refactorings specified by the refact library.
Safe HaskellNone
LanguageHaskell2010

Refact.Apply

Synopsis

Documentation

applyRefactorings Source #

Arguments

:: Maybe (Int, Int)

Apply hints relevant to a specific position

-> [[Refactoring SrcSpan]]

Refactorings to apply. Each inner list corresponds to an HLint Idea. An Idea may have more than one Refactoring.

The Ideas are sorted in ascending order of starting location, and are applied in that order. If two Ideas start at the same location, the one with the larger source span comes first. An Idea is filtered out (ignored) if there is an Idea prior to it which has an overlapping source span and is not filtered out.

-> FilePath

Target file

-> [String]

GHC extensions, e.g., LambdaCase, NoStarIsType. The list is processed from left to right. An extension (e.g., StarIsType) may be overridden later (e.g., by NoStarIsType).

These are in addition to the LANGUAGE pragmas in the target file. When they conflict with the LANGUAGE pragmas, pragmas win.

-> IO String 

Apply a set of refactorings as supplied by HLint

applyRefactorings' Source #

Arguments

:: Maybe (Int, Int) 
-> [[Refactoring SrcSpan]] 
-> Anns

ghc-exactprint AST annotations. This can be obtained from postParseTransform.

-> Module

Parsed module

-> IO String 

Like applyRefactorings, but takes a parsed module rather than a file path to parse.

runRefactoring :: Data a => Anns -> a -> AnnKeyMap -> Refactoring SrcSpan -> StateT Int IO (Anns, a, AnnKeyMap) Source #

Peform a Refactoring.

parseExtensions :: [String] -> ([Extension], [Extension], [String]) Source #

Parse the input into (enabled extensions, disabled extensions, invalid input). Implied extensions are automatically added. For example, FunctionalDependencies implies MultiParamTypeClasses, and RebindableSyntax implies NoImplicitPrelude.

The input is processed from left to right. An extension (e.g., StarIsType) may be overridden later (e.g., by NoStarIsType).

Extensions that appear earlier in the input will appear later in the output. Implied extensions appear in the end. If an extension occurs multiple times in the input, the last one is used.

>>> parseExtensions ["GADTs", "RebindableSyntax", "StarIsType", "GADTs", "InvalidExtension", "NoStarIsType"]
([GADTs, RebindableSyntax, GADTSyntax, MonoLocalBinds], [StarIsType, ImplicitPrelude], ["InvalidExtension"])