-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Refactoring Tool for Haskell -- -- Contains a set of refactorings based on the Haskell-Tools framework to -- easily transform a Haskell program. For the descriptions of the -- implemented refactorings, see the homepage. @package haskell-tools-refactor @version 0.4.1.2 module Language.Haskell.Tools.Refactor.RefactorBase type UnnamedModule dom = Ann UModule dom SrcTemplateStage -- | The name of the module and the AST type ModuleDom dom = (SourceFileKey, UnnamedModule dom) -- | Module name and marker to separate .hs-boot module definitions. -- Specifies a source file in a working directory. data SourceFileKey SourceFileKey :: IsBoot -> String -> SourceFileKey [_sfkIsBoot] :: SourceFileKey -> IsBoot [_sfkModuleName] :: SourceFileKey -> String -- | Decides if a module is a .hs-boot file or a normal .hs file data IsBoot NormalHs :: IsBoot IsHsBoot :: IsBoot -- | A refactoring that only affects one module type LocalRefactoring dom = UnnamedModule dom -> LocalRefactor dom (UnnamedModule dom) -- | The type of a refactoring type Refactoring dom = ModuleDom dom -> [ModuleDom dom] -> Refactor [RefactorChange dom] -- | Change in the project, modification or removal of a module. data RefactorChange dom ContentChanged :: (ModuleDom dom) -> RefactorChange dom [fromContentChanged] :: RefactorChange dom -> (ModuleDom dom) ModuleRemoved :: String -> RefactorChange dom [removedModuleName] :: RefactorChange dom -> String ModuleCreated :: String -> UnnamedModule dom -> SourceFileKey -> RefactorChange dom [createdModuleName] :: RefactorChange dom -> String [createdModuleContent] :: RefactorChange dom -> UnnamedModule dom [sameLocation] :: RefactorChange dom -> SourceFileKey -- | Performs the given refactoring, transforming it into a Ghc action runRefactor :: ModuleDom dom -> [ModuleDom dom] -> Refactoring dom -> Ghc (Either String [RefactorChange dom]) -- | Wraps a refactoring that only affects one module. Performs the -- per-module finishing touches. localRefactoring :: HasModuleInfo dom => LocalRefactoring dom -> Refactoring dom -- | Transform the result of the local refactoring localRefactoringRes :: HasModuleInfo dom => ((UnnamedModule dom -> UnnamedModule dom) -> a -> a) -> UnnamedModule dom -> LocalRefactor dom a -> Refactor a -- | Adds the imports that bring names into scope that are needed by the -- refactoring addGeneratedImports :: [Name] -> Ann UModule dom SrcTemplateStage -> Ann UModule dom SrcTemplateStage -- | Input and output information for the refactoring newtype LocalRefactorT dom m a LocalRefactorT :: WriterT [Name] (ReaderT (RefactorCtx dom) m) a -> LocalRefactorT dom m a [fromRefactorT] :: LocalRefactorT dom m a -> WriterT [Name] (ReaderT (RefactorCtx dom) m) a -- | The information a refactoring can use data RefactorCtx dom RefactorCtx :: Module -> Ann UModule dom SrcTemplateStage -> [Ann UImportDecl dom SrcTemplateStage] -> RefactorCtx dom [refModuleName] :: RefactorCtx dom -> Module [refCtxRoot] :: RefactorCtx dom -> Ann UModule dom SrcTemplateStage [refCtxImports] :: RefactorCtx dom -> [Ann UImportDecl dom SrcTemplateStage] -- | A monad that can be used to refactor class Monad m => RefactorMonad m refactError :: RefactorMonad m => String -> m a liftGhc :: RefactorMonad m => Ghc a -> m a -- | The refactoring monad for a given module type LocalRefactor dom = LocalRefactorT dom Refactor -- | The refactoring monad for the whole project type Refactor = ExceptT String Ghc registeredNamesFromPrelude :: [Name] otherNamesFromPrelude :: [String] qualifiedName :: Name -> String referenceName :: (HasImportInfo dom, HasModuleInfo dom) => Name -> LocalRefactor dom (Ann UName dom SrcTemplateStage) referenceOperator :: (HasImportInfo dom, HasModuleInfo dom) => Name -> LocalRefactor dom (Ann UOperator dom SrcTemplateStage) -- | Create a name that references the definition. Generates an import if -- the definition is not yet imported. referenceName' :: (HasImportInfo dom, HasModuleInfo dom) => ([String] -> Name -> Ann nt dom SrcTemplateStage) -> Name -> LocalRefactor dom (Ann nt dom SrcTemplateStage) -- | Reference the name by the shortest suitable import referenceBy :: ([String] -> Name -> Ann nt dom SrcTemplateStage) -> Name -> [Ann UImportDecl dom SrcTemplateStage] -> Ann nt dom SrcTemplateStage -- | Different classes of definitions that have different kind of names. data NameClass -- | Normal value definitions: functions, variables Variable :: NameClass -- | Data constructors Ctor :: NameClass -- | Functions with operator-like names ValueOperator :: NameClass -- | Constructors with operator-like names DataCtorOperator :: NameClass -- | UType definitions with operator-like names SynonymOperator :: NameClass -- | Get which category does a given name belong to classifyName :: RefactorMonad m => Name -> m NameClass -- | Checks if a given name is a valid module name validModuleName :: String -> Bool -- | Check if a given name is valid for a given kind of definition nameValid :: NameClass -> String -> Bool isIdStartChar :: Char -> Bool isOperatorChar :: Char -> Bool sfkModuleName :: Lens SourceFileKey SourceFileKey String String sfkIsBoot :: Lens SourceFileKey SourceFileKey IsBoot IsBoot instance GhcMonad.GhcMonad m => GhcMonad.GhcMonad (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance Exception.ExceptionMonad m => Exception.ExceptionMonad (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance (DynFlags.HasDynFlags m, GHC.Base.Monad m) => DynFlags.HasDynFlags (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Base.Monad m => Control.Monad.Writer.Class.MonadWriter [Name.Name] (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader (Language.Haskell.Tools.Refactor.RefactorBase.RefactorCtx dom) (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Base.Monad m => GHC.Base.Monad (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Base.Functor m => GHC.Base.Functor (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom m) instance GHC.Show.Show Language.Haskell.Tools.Refactor.RefactorBase.SourceFileKey instance GHC.Classes.Ord Language.Haskell.Tools.Refactor.RefactorBase.SourceFileKey instance GHC.Classes.Eq Language.Haskell.Tools.Refactor.RefactorBase.SourceFileKey instance GHC.Show.Show Language.Haskell.Tools.Refactor.RefactorBase.IsBoot instance GHC.Classes.Ord Language.Haskell.Tools.Refactor.RefactorBase.IsBoot instance GHC.Classes.Eq Language.Haskell.Tools.Refactor.RefactorBase.IsBoot instance GHC.Show.Show (Language.Haskell.Tools.Refactor.RefactorBase.RefactorChange dom) instance (GhcMonad.GhcMonad m, GHC.Base.Monoid s) => GhcMonad.GhcMonad (Control.Monad.Trans.Writer.Lazy.WriterT s m) instance (Exception.ExceptionMonad m, GHC.Base.Monoid s) => Exception.ExceptionMonad (Control.Monad.Trans.Writer.Lazy.WriterT s m) instance (GHC.Base.Monad m, DynFlags.HasDynFlags m) => DynFlags.HasDynFlags (Control.Monad.Trans.State.Lazy.StateT s m) instance GhcMonad.GhcMonad m => GhcMonad.GhcMonad (Control.Monad.Trans.State.Lazy.StateT s m) instance Exception.ExceptionMonad m => Exception.ExceptionMonad (Control.Monad.Trans.State.Lazy.StateT s m) instance GhcMonad.GhcMonad m => GhcMonad.GhcMonad (Control.Monad.Trans.Reader.ReaderT s m) instance Exception.ExceptionMonad m => Exception.ExceptionMonad (Control.Monad.Trans.Reader.ReaderT s m) instance GhcMonad.GhcMonad m => GhcMonad.GhcMonad (Control.Monad.Trans.Except.ExceptT s m) instance Exception.ExceptionMonad m => Exception.ExceptionMonad (Control.Monad.Trans.Except.ExceptT s m) instance Control.Monad.Trans.Class.MonadTrans (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactorT dom) instance Language.Haskell.Tools.Refactor.RefactorBase.RefactorMonad Language.Haskell.Tools.Refactor.RefactorBase.Refactor instance Language.Haskell.Tools.Refactor.RefactorBase.RefactorMonad (Language.Haskell.Tools.Refactor.RefactorBase.LocalRefactor dom) instance Language.Haskell.Tools.Refactor.RefactorBase.RefactorMonad m => Language.Haskell.Tools.Refactor.RefactorBase.RefactorMonad (Control.Monad.Trans.State.Lazy.StateT s m) -- | Defines utility methods that prepare Haskell modules for refactoring module Language.Haskell.Tools.Refactor.Prepare tryRefactor :: (RealSrcSpan -> Refactoring IdDom) -> String -> String -> IO () -- | Adjust the source range to be applied to the refactored module correctRefactorSpan :: UnnamedModule dom -> RealSrcSpan -> RealSrcSpan -- | Set the given flags for the GHC session useFlags :: [String] -> Ghc [String] -- | Initialize GHC flags to default values that support refactoring initGhcFlags :: Ghc () initGhcFlagsForTest :: Ghc () initGhcFlags' :: Bool -> Ghc () -- | Use the given source directories useDirs :: [FilePath] -> Ghc () deregisterDirs :: [FilePath] -> Ghc () -- | Translates module name and working directory into the name of the file -- where the given module should be defined toFileName :: FilePath -> String -> FilePath -- | Translates module name and working directory into the name of the file -- where the boot module should be defined toBootFileName :: FilePath -> String -> FilePath getSourceDir :: ModSummary -> IO FilePath getModSumOrig :: ModSummary -> FilePath -- | Load the summary of a module given by the working directory and module -- name. loadModule :: String -> String -> Ghc ModSummary -- | The final version of our AST, with type infromation added type TypedModule = Ann UModule IdDom SrcTemplateStage -- | Get the typed representation from a type-correct program. parseTyped :: ModSummary -> Ghc TypedModule -- | Modifies the dynamic flags for performing a ghc task withAlteredDynFlags :: GhcMonad m => (DynFlags -> m DynFlags) -> m a -> m a -- | Forces the code generation for a given module forceCodeGen :: ModSummary -> ModSummary -- | Forces ASM code generation for a given module forceAsmGen :: ModSummary -> ModSummary -- | Normalizes the flags for a module summary modSumNormalizeFlags :: ModSummary -> ModSummary -- | Removes all flags that are unintelligable for refactoring normalizeFlags :: DynFlags -> DynFlags readSrcSpan :: String -> RealSrcSpan readSrcLoc :: String -> RealSrcLoc -- | Defines operation on AST lists. AST lists carry source information so -- simple list modification is not enough. module Language.Haskell.Tools.Refactor.ListOperations -- | Filters the elements of the list. By default it removes the separator -- before the element. Of course, if the first element is removed, the -- following separator is removed as well. filterList :: (Ann e dom SrcTemplateStage -> Bool) -> AnnList e dom -> AnnList e dom filterListIndexed :: (Int -> Ann e dom SrcTemplateStage -> Bool) -> AnnList e dom -> AnnList e dom -- | Inserts the element in the places where the two positioning functions -- (one checks the element before, one the element after) allows the -- placement. insertWhere :: Ann e dom SrcTemplateStage -> (Maybe (Ann e dom SrcTemplateStage) -> Bool) -> (Maybe (Ann e dom SrcTemplateStage) -> Bool) -> AnnList e dom -> AnnList e dom -- | Checks where the element will be inserted given the two positioning -- functions. insertIndex :: (Maybe (Ann e dom SrcTemplateStage) -> Bool) -> (Maybe (Ann e dom SrcTemplateStage) -> Bool) -> [Ann e dom SrcTemplateStage] -> Maybe Int zipWithSeparators :: AnnList e dom -> [(String, Ann e dom SrcTemplateStage)] replaceWithJust :: Ann e dom SrcTemplateStage -> AnnMaybe e dom -> AnnMaybe e dom module Language.Haskell.Tools.Refactor.GetModules -- | The modules of a library, executable, test or benchmark. A package -- contains one or more module collection. data ModuleCollection ModuleCollection :: ModuleCollectionId -> FilePath -> [FilePath] -> Map SourceFileKey ModuleRecord -> (DynFlags -> IO DynFlags) -> [ModuleCollectionId] -> ModuleCollection [_mcId] :: ModuleCollection -> ModuleCollectionId [_mcRoot] :: ModuleCollection -> FilePath [_mcSourceDirs] :: ModuleCollection -> [FilePath] [_mcModules] :: ModuleCollection -> Map SourceFileKey ModuleRecord -- | Sets up the ghc environment for compiling the modules of this -- collection [_mcFlagSetup] :: ModuleCollection -> DynFlags -> IO DynFlags [_mcDependencies] :: ModuleCollection -> [ModuleCollectionId] data ModuleRecord ModuleNotLoaded :: Bool -> ModuleRecord [_recModuleWillNeedCode] :: ModuleRecord -> Bool ModuleParsed :: UnnamedModule (Dom RdrName) -> ModSummary -> ModuleRecord [_parsedRecModule] :: ModuleRecord -> UnnamedModule (Dom RdrName) [_modRecMS] :: ModuleRecord -> ModSummary ModuleRenamed :: UnnamedModule (Dom Name) -> ModSummary -> ModuleRecord [_renamedRecModule] :: ModuleRecord -> UnnamedModule (Dom Name) [_modRecMS] :: ModuleRecord -> ModSummary ModuleTypeChecked :: UnnamedModule IdDom -> ModSummary -> ModuleRecord [_typedRecModule] :: ModuleRecord -> UnnamedModule IdDom [_modRecMS] :: ModuleRecord -> ModSummary ModuleCodeGenerated :: UnnamedModule IdDom -> ModSummary -> ModuleRecord [_typedRecModule] :: ModuleRecord -> UnnamedModule IdDom [_modRecMS] :: ModuleRecord -> ModSummary -- | This data structure identifies a module collection data ModuleCollectionId DirectoryMC :: FilePath -> ModuleCollectionId LibraryMC :: String -> ModuleCollectionId ExecutableMC :: String -> String -> ModuleCollectionId TestSuiteMC :: String -> String -> ModuleCollectionId BenchmarkMC :: String -> String -> ModuleCollectionId moduleCollectionIdString :: ModuleCollectionId -> String moduleCollectionPkgId :: ModuleCollectionId -> Maybe String mcSourceDirs :: Lens ModuleCollection ModuleCollection [FilePath] [FilePath] mcRoot :: Lens ModuleCollection ModuleCollection FilePath FilePath mcModules :: Lens ModuleCollection ModuleCollection (Map SourceFileKey ModuleRecord) (Map SourceFileKey ModuleRecord) mcId :: Lens ModuleCollection ModuleCollection ModuleCollectionId ModuleCollectionId mcFlagSetup :: Lens ModuleCollection ModuleCollection (DynFlags -> IO DynFlags) (DynFlags -> IO DynFlags) mcDependencies :: Lens ModuleCollection ModuleCollection [ModuleCollectionId] [ModuleCollectionId] typedRecModule :: Partial ModuleRecord ModuleRecord (UnnamedModule IdDom) (UnnamedModule IdDom) renamedRecModule :: Partial ModuleRecord ModuleRecord (UnnamedModule (Dom Name)) (UnnamedModule (Dom Name)) recModuleWillNeedCode :: Partial ModuleRecord ModuleRecord Bool Bool parsedRecModule :: Partial ModuleRecord ModuleRecord (UnnamedModule (Dom RdrName)) (UnnamedModule (Dom RdrName)) modRecMS :: Partial ModuleRecord ModuleRecord ModSummary ModSummary lookupModuleColl :: String -> [ModuleCollection] -> Maybe (ModuleCollection) lookupModInSCs :: SourceFileKey -> [ModuleCollection] -> Maybe (SourceFileKey, ModuleRecord) removeModule :: String -> [ModuleCollection] -> [ModuleCollection] hasGeneratedCode :: SourceFileKey -> [ModuleCollection] -> Bool needsGeneratedCode :: SourceFileKey -> [ModuleCollection] -> Bool codeGeneratedFor :: SourceFileKey -> [ModuleCollection] -> [ModuleCollection] isAlreadyLoaded :: SourceFileKey -> [ModuleCollection] -> Bool -- | Gets all ModuleCollections from a list of source directories. It also -- orders the source directories that are package roots so that they can -- be loaded in the order they are defined (no backward imports). This -- matters in those cases because for them there can be special -- compilation flags. getAllModules :: [FilePath] -> IO [ModuleCollection] -- | Sorts model collection in an order to remove all backward references. -- Works because module collections defined by directories cannot be -- recursive. orderMCs :: [ModuleCollection] -> [ModuleCollection] -- | Get modules of the project with the indicated root directory. If there -- is a cabal file, it uses that, otherwise it just scans the directory -- recursively for haskell sourcefiles. Only returns the non-boot haskell -- modules, the boot modules will be found during loading. getModules :: FilePath -> IO [ModuleCollection] modulesFromDirectory :: FilePath -> FilePath -> IO [String] srcDirFromRoot :: FilePath -> String -> FilePath modulesFromCabalFile :: FilePath -> FilePath -> IO [ModuleCollection] class ToModuleCollection t mkModuleCollKey :: ToModuleCollection t => PackageName -> t -> ModuleCollectionId getBuildInfo :: ToModuleCollection t => t -> BuildInfo getModuleNames :: ToModuleCollection t => t -> [ModuleName] compileInContext :: ModuleCollection -> [ModuleCollection] -> DynFlags -> IO DynFlags applyDependencies :: [ModuleCollection] -> [ModuleCollectionId] -> DynFlags -> DynFlags dependencyToPkgFlag :: [ModuleCollection] -> ModuleCollectionId -> Maybe (PackageFlag) enableAllPackages :: [ModuleCollection] -> DynFlags -> DynFlags flagsFromBuildInfo :: BuildInfo -> DynFlags -> IO DynFlags instance GHC.Show.Show Language.Haskell.Tools.Refactor.GetModules.ModuleRecord instance Language.Haskell.Tools.Refactor.GetModules.ToModuleCollection Distribution.PackageDescription.Library instance Language.Haskell.Tools.Refactor.GetModules.ToModuleCollection Distribution.PackageDescription.Executable instance Language.Haskell.Tools.Refactor.GetModules.ToModuleCollection Distribution.PackageDescription.TestSuite instance Language.Haskell.Tools.Refactor.GetModules.ToModuleCollection Distribution.PackageDescription.Benchmark instance GHC.Show.Show Language.Haskell.Tools.Refactor.GetModules.ModuleCollectionId instance GHC.Classes.Ord Language.Haskell.Tools.Refactor.GetModules.ModuleCollectionId instance GHC.Classes.Eq Language.Haskell.Tools.Refactor.GetModules.ModuleCollectionId instance GHC.Classes.Eq Language.Haskell.Tools.Refactor.GetModules.ModuleCollection instance GHC.Show.Show Language.Haskell.Tools.Refactor.GetModules.ModuleCollection module Language.Haskell.Tools.Refactor.Session data RefactorSessionState RefactorSessionState :: [ModuleCollection] -> RefactorSessionState [__refSessMCs] :: RefactorSessionState -> [ModuleCollection] _refSessMCs :: Lens RefactorSessionState RefactorSessionState [ModuleCollection] [ModuleCollection] class IsRefactSessionState st refSessMCs :: IsRefactSessionState st => Simple Lens st [ModuleCollection] initSession :: IsRefactSessionState st => st loadPackagesFrom :: IsRefactSessionState st => (ModSummary -> IO a) -> [FilePath] -> StateT st Ghc (Either String ([a], [String])) handleErrors :: ExceptionMonad m => m a -> m (Either String a) keyFromMS :: ModSummary -> SourceFileKey getMods :: (Monad m, IsRefactSessionState st) => Maybe SourceFileKey -> StateT st m (Maybe (SourceFileKey, UnnamedModule IdDom), [(SourceFileKey, UnnamedModule IdDom)]) getFileMods :: (GhcMonad m, IsRefactSessionState st) => FilePath -> StateT st m (Maybe (SourceFileKey, UnnamedModule IdDom), [(SourceFileKey, UnnamedModule IdDom)]) reloadChangedModules :: IsRefactSessionState st => (ModSummary -> IO a) -> (ModSummary -> Bool) -> StateT st Ghc (Either String [a]) getReachableModules :: IsRefactSessionState st => (ModSummary -> Bool) -> StateT st Ghc [ModSummary] reloadModule :: IsRefactSessionState st => (ModSummary -> IO a) -> ModSummary -> StateT st Ghc a checkEvaluatedMods :: IsRefactSessionState st => (ModSummary -> IO a) -> [ModSummary] -> StateT st Ghc [a] codeGenForModule :: (ModSummary -> IO a) -> [ModuleCollection] -> ModSummary -> Ghc a -- | Check which modules can be reached from the module, if it uses -- template haskell. getEvaluatedMods :: [ModSummary] -> Ghc [ModSummary] modSumName :: ModSummary -> String type NodeKey = (ModuleName, IsBoot) type NodeMap a = Map NodeKey a type SummaryNode = (ModSummary, Int, [Int]) getModFromNode :: SummaryNode -> ModSummary moduleGraphNodes :: Bool -> [ModSummary] -> (Graph SummaryNode, HscSource -> ModuleName -> Maybe SummaryNode) hscSourceToIsBoot :: HscSource -> IsBoot summaryNodeKey :: SummaryNode -> Int ms_home_imps :: ModSummary -> [Located ModuleName] ms_home_srcimps :: ModSummary -> [Located ModuleName] home_imps :: [(Maybe FastString, Located ModuleName)] -> [Located ModuleName] instance Language.Haskell.Tools.Refactor.Session.IsRefactSessionState Language.Haskell.Tools.Refactor.Session.RefactorSessionState -- | Utilities for transformations that work on both top-level and local -- definitions module Language.Haskell.Tools.Refactor.BindingElem -- | A type class for handling definitions that can appear as both -- top-level and local definitions class NamedElement d => BindingElem d -- | Accesses a type signature definition in a local or top-level -- definition sigBind :: BindingElem d => Simple Partial (Ann d dom SrcTemplateStage) (TypeSignature dom) -- | Accesses a value or function definition in a local or top-level -- definition valBind :: BindingElem d => Simple Partial (Ann d dom SrcTemplateStage) (ValueBind dom) -- | Accesses a type signature definition in a local or top-level -- definition fixitySig :: BindingElem d => Simple Partial (Ann d dom SrcTemplateStage) (FixitySignature dom) -- | Creates a new definition from a type signature createTypeSig :: BindingElem d => TypeSignature dom -> Ann d dom SrcTemplateStage -- | Creates a new definition from a value or function definition createBinding :: BindingElem d => ValueBind dom -> Ann d dom SrcTemplateStage -- | Creates a new fixity signature createFixitySig :: BindingElem d => FixitySignature dom -> Ann d dom SrcTemplateStage -- | Checks if a given definition is a type signature isTypeSig :: BindingElem d => Ann d dom SrcTemplateStage -> Bool -- | Checks if a given definition is a function or value binding isBinding :: BindingElem d => Ann d dom SrcTemplateStage -> Bool -- | Checks if a given definition is a fixity signature isFixitySig :: BindingElem d => Ann d dom SrcTemplateStage -> Bool getValBindInList :: (BindingElem d) => RealSrcSpan -> AnnListG d dom SrcTemplateStage -> Maybe (ValueBind dom) valBindsInList :: BindingElem d => Simple Traversal (AnnListG d dom SrcTemplateStage) (ValueBind dom) instance Language.Haskell.Tools.Refactor.BindingElem.BindingElem Language.Haskell.Tools.AST.Representation.Decls.UDecl instance Language.Haskell.Tools.Refactor.BindingElem.BindingElem Language.Haskell.Tools.AST.Representation.Binds.ULocalBind -- | Defines the API for refactorings module Language.Haskell.Tools.Refactor class HasSourceInfo e where type SourceInfoType e :: * where { type family SourceInfoType e :: *; } srcInfo :: HasSourceInfo e => Simple Lens e (SourceInfoType e) -- | Extracts or modifies the concrete range corresponding to a given -- source info. In case of lists and optional elements, it may not -- contain the elements inside. class HasRange a getRange :: HasRange a => a -> SrcSpan setRange :: HasRange a => SrcSpan -> a -> a annListElems :: RefMonads w r => Reference w r (MU *) (MU *) (AnnListG elem0 dom0 stage0) (AnnListG elem0 dom0 stage0) [Ann elem0 dom0 stage0] [Ann elem0 dom0 stage0] annListAnnot :: RefMonads w r => Reference w r (MU *) (MU *) (AnnListG elem0 dom0 stage0) (AnnListG elem0 dom0 stage0) (NodeInfo (SemanticInfo dom0 (AnnListG elem0)) (ListInfo stage0)) (NodeInfo (SemanticInfo dom0 (AnnListG elem0)) (ListInfo stage0)) annList :: (RefMonads w r, MonadPlus r, Morph Maybe r, Morph [] r) => Reference w r (MU *) (MU *) (AnnListG e d s) (AnnListG e d s) (Ann e d s) (Ann e d s) annJust :: (Functor w, Applicative w, Monad w, Functor r, Applicative r, MonadPlus r, Morph Maybe r) => Reference w r (MU *) (MU *) (AnnMaybeG e d s) (AnnMaybeG e d s) (Ann e d s) (Ann e d s) annMaybe :: RefMonads w r => Reference w r (MU *) (MU *) (AnnMaybeG elem0 dom0 stage0) (AnnMaybeG elem0 dom0 stage0) (Maybe (Ann elem0 dom0 stage0)) (Maybe (Ann elem0 dom0 stage0)) isAnnNothing :: AnnMaybeG e d s -> Bool -- | Class for domain configuration markers class (Typeable * d, Data d, (~) * (SemanticInfo' d SameInfoDefaultCls) NoSemanticInfo, Data (SemanticInfo' d SameInfoNameCls), Data (SemanticInfo' d SameInfoExprCls), Data (SemanticInfo' d SameInfoImportCls), Data (SemanticInfo' d SameInfoModuleCls), Data (SemanticInfo' d SameInfoWildcardCls), Show (SemanticInfo' d SameInfoNameCls), Show (SemanticInfo' d SameInfoExprCls), Show (SemanticInfo' d SameInfoImportCls), Show (SemanticInfo' d SameInfoModuleCls), Show (SemanticInfo' d SameInfoWildcardCls)) => Domain d -- | A short form of showing a range, without file name, for debugging -- purposes. shortShowSpan :: SrcSpan -> String -- | A stage where the annotation controls how the original source code can -- be retrieved from the AST. A source template is assigned to each node. -- It has holes where the content of an other node should be printed and -- ranges for the source code of the node. data SrcTemplateStage :: * -- | A class for traversing source information in an AST class SourceInfoTraversal (a :: * -> * -> *) sourceInfoTraverseUp :: (SourceInfoTraversal a, Monad f) => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) sourceInfoTraverseDown :: (SourceInfoTraversal a, Monad f) => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) sourceInfoTraverse :: (SourceInfoTraversal a, Monad f) => SourceInfoTrf f st1 st2 -> a dom st1 -> f (a dom st2) sourceTemplateNodeRange :: Simple Lens (SpanInfo SrcTemplateStage) SrcSpan sourceTemplateNodeElems :: Simple Lens (SpanInfo SrcTemplateStage) [SourceTemplateElem] sourceTemplateListRange :: Simple Lens (ListInfo SrcTemplateStage) SrcSpan srcTmpListBefore :: Simple Lens (ListInfo SrcTemplateStage) String srcTmpListAfter :: Simple Lens (ListInfo SrcTemplateStage) String srcTmpDefaultSeparator :: Simple Lens (ListInfo SrcTemplateStage) String srcTmpIndented :: Simple Lens (ListInfo SrcTemplateStage) Bool srcTmpSeparators :: Simple Lens (ListInfo SrcTemplateStage) [String] sourceTemplateOptRange :: Simple Lens (OptionalInfo SrcTemplateStage) SrcSpan srcTmpOptBefore :: Simple Lens (OptionalInfo SrcTemplateStage) String srcTmpOptAfter :: Simple Lens (OptionalInfo SrcTemplateStage) String module Language.Haskell.Tools.Refactor.Predefined.DataToNewtype dataToNewtype :: LocalRefactoring dom tryItOut :: String -> IO () module Language.Haskell.Tools.Refactor.Predefined.DollarApp dollarApp :: DollarDomain dom => RealSrcSpan -> LocalRefactoring dom type DollarDomain dom = (HasImportInfo dom, HasModuleInfo dom, HasFixityInfo dom, HasNameInfo dom) tryItOut :: String -> String -> IO () module Language.Haskell.Tools.Refactor.Predefined.ExtractBinding extractBinding' :: ExtractBindingDomain dom => RealSrcSpan -> String -> LocalRefactoring dom type ExtractBindingDomain dom = (HasNameInfo dom, HasDefiningInfo dom, HasScopeInfo dom) tryItOut :: String -> String -> String -> IO () module Language.Haskell.Tools.Refactor.Predefined.GenerateExports -- | Creates an export list that imports standalone top-level definitions -- with all of their contained definitions generateExports :: DomGenerateExports dom => LocalRefactoring dom type DomGenerateExports dom = (Domain dom, HasNameInfo dom) module Language.Haskell.Tools.Refactor.Predefined.GenerateTypeSignature -- | Perform the refactoring on either local or top-level definition generateTypeSignature :: GenerateSignatureDomain dom => Simple Traversal (Module dom) (DeclList dom) -> Simple Traversal (Module dom) (LocalBindList dom) -> (forall d. (BindingElem d) => AnnList d dom -> Maybe (ValueBind dom)) -> LocalRefactoring dom generateTypeSignature' :: GenerateSignatureDomain dom => RealSrcSpan -> LocalRefactoring dom type GenerateSignatureDomain dom = (HasModuleInfo dom, HasIdInfo dom, HasImportInfo dom, HasScopeInfo dom) tryItOut :: String -> String -> IO () module Language.Haskell.Tools.Refactor.Predefined.IfToGuards ifToGuards :: Domain dom => RealSrcSpan -> LocalRefactoring dom tryItOut :: String -> String -> IO () -- | Defines the inline binding refactoring that removes a value binding -- and replaces all occurences with an expression equivalent to the body -- of the binding. module Language.Haskell.Tools.Refactor.Predefined.InlineBinding inlineBinding :: forall dom. InlineBindingDomain dom => RealSrcSpan -> Refactoring dom type InlineBindingDomain dom = (HasNameInfo dom, HasDefiningInfo dom, HasScopeInfo dom, HasModuleInfo dom) tryItOut :: String -> String -> IO () module Language.Haskell.Tools.Refactor.Predefined.OrganizeImports organizeImports :: forall dom. OrganizeImportsDomain dom => LocalRefactoring dom type OrganizeImportsDomain dom = (HasNameInfo dom, HasImportInfo dom, HasModuleInfo dom) projectOrganizeImports :: forall dom. OrganizeImportsDomain dom => Refactoring dom module Language.Haskell.Tools.Refactor.Predefined.RenameDefinition renameDefinition :: DomainRenameDefinition dom => Name -> [Name] -> String -> Refactoring dom renameDefinition' :: forall dom. DomainRenameDefinition dom => RealSrcSpan -> String -> Refactoring dom type DomainRenameDefinition dom = (HasNameInfo dom, HasScopeInfo dom, HasDefiningInfo dom, HasImplicitFieldsInfo dom, HasModuleInfo dom) -- | Defines common utilities for using refactorings. Provides an interface -- for both demo, command line and integrated tools. module Language.Haskell.Tools.Refactor.Perform -- | Executes a given command on the selected module and given other -- modules performCommand :: (HasModuleInfo dom, DomGenerateExports dom, OrganizeImportsDomain dom, DomainRenameDefinition dom, ExtractBindingDomain dom, GenerateSignatureDomain dom) => RefactorCommand -> ModuleDom dom -> [ModuleDom dom] -> Ghc (Either String [RefactorChange dom]) -- | A refactoring command data RefactorCommand NoRefactor :: RefactorCommand OrganizeImports :: RefactorCommand ProjectOrganizeImports :: RefactorCommand GenerateExports :: RefactorCommand GenerateSignature :: RealSrcSpan -> RefactorCommand RenameDefinition :: RealSrcSpan -> String -> RefactorCommand ExtractBinding :: RealSrcSpan -> String -> RefactorCommand InlineBinding :: RealSrcSpan -> RefactorCommand readCommand :: String -> RefactorCommand analyzeCommand :: String -> [String] -> RefactorCommand instance GHC.Show.Show Language.Haskell.Tools.Refactor.Perform.RefactorCommand