-- 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.1.2.0 module Language.Haskell.Tools.Refactor.RefactorBase -- | The information a refactoring can use data RefactorCtx a RefactorCtx :: Module -> [Ann ImportDecl a] -> RefactorCtx a [refModuleName] :: RefactorCtx a -> Module [refCtxImports] :: RefactorCtx a -> [Ann ImportDecl a] -- | Performs the given refactoring, transforming it into a Ghc action runRefactor :: (a ~ STWithNames n, TemplateAnnot a) => Ann Module a -> (Ann Module a -> Refactor n (Ann Module a)) -> Ghc (Either String (Ann Module a)) -- | Adds the imports that bring names into scope that are needed by the -- refactoring addGeneratedImports :: (TemplateAnnot a, Monad m) => ReaderT (RefactorCtx a) m (Ann Module a, [Name]) -> ReaderT (RefactorCtx a) m (Ann Module a) -- | Input and output information for the refactoring newtype RefactorT ann m ast RefactorT :: WriterT [Name] (ReaderT (RefactorCtx ann) m) ast -> RefactorT ann m ast [fromRefactorT] :: RefactorT ann m ast -> WriterT [Name] (ReaderT (RefactorCtx ann) m) ast refactError :: String -> Refactor n a -- | The refactoring monad type Refactor n = RefactorT (STWithNames n) (ExceptT String Ghc) type STWithNames n = NodeInfo (SemanticInfo n) SourceTemplate type RefactoredModule n = Refactor n (Ann Module (STWithNames n)) registeredNamesFromPrelude :: [Name] otherNamesFromPrelude :: [String] qualifiedName :: Name -> String referenceName :: (Eq n, NamedThing n) => n -> Refactor n (Ann Name (STWithNames n)) referenceOperator :: (Eq n, NamedThing n) => n -> Refactor n (Ann Operator (STWithNames n)) -- | Create a name that references the definition. Generates an import if -- the definition is not yet imported. referenceName' :: (Eq n, NamedThing n) => ([String] -> Name -> Ann nt (STWithNames n)) -> n -> Refactor n (Ann nt (STWithNames n)) -- | Reference the name by the shortest suitable import referenceBy :: (TemplateAnnot a) => ([String] -> Name -> Ann nt a) -> Name -> [Ann ImportDecl a] -> Ann nt a -- | 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 -- | Type definitions with operator-like names SynonymOperator :: NameClass -- | Get which category does a given name belong to classifyName :: Name -> Refactor n NameClass -- | Check if a given name is valid for a given kind of definition nameValid :: NameClass -> String -> Bool isIdStartChar :: Char -> Bool isOperatorChar :: Char -> Bool instance GhcMonad.GhcMonad m => GhcMonad.GhcMonad (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance Exception.ExceptionMonad m => Exception.ExceptionMonad (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance (GHC.Base.Monad m, DynFlags.HasDynFlags m) => DynFlags.HasDynFlags (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance GHC.Base.Monad m => Control.Monad.Writer.Class.MonadWriter [Name.Name] (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader (Language.Haskell.Tools.Refactor.RefactorBase.RefactorCtx ann) (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance GHC.Base.Monad m => GHC.Base.Monad (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) instance GHC.Base.Functor m => GHC.Base.Functor (Language.Haskell.Tools.Refactor.RefactorBase.RefactorT ann m) 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 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.RefactorT ann) module Language.Haskell.Tools.Refactor.ExtractBinding type STWithId = STWithNames Id extractBinding' :: RealSrcSpan -> String -> Ann Module STWithId -> RefactoredModule Id extractBinding :: Simple Traversal (Ann Module STWithId) (Ann ValueBind STWithId) -> Simple Traversal (Ann ValueBind STWithId) (Ann Expr STWithId) -> String -> Ann Module STWithId -> RefactoredModule Id isConflicting :: String -> Ann SimpleName STWithId -> Bool extractThatBind :: String -> Ann Expr STWithId -> Ann Expr STWithId -> StateT (Maybe (Ann ValueBind STWithId)) (Refactor Id) (Ann Expr STWithId) addLocalBinding :: SrcSpan -> SrcSpan -> Ann ValueBind STWithId -> ValueBind STWithId -> State Bool (ValueBind STWithId) insertLocalBind :: SrcSpan -> Ann ValueBind STWithId -> AnnMaybe LocalBinds STWithId -> AnnMaybe LocalBinds STWithId -- | All expressions that are bound stronger than function application. isParenLikeExpr :: Expr a -> Bool doExtract :: String -> Ann Expr STWithId -> Ann Expr STWithId -> StateT (Maybe (Ann ValueBind STWithId)) (Refactor Id) (Ann Expr STWithId) -- | Gets the values that have to be passed to the extracted definition getExternalBinds :: Ann Expr STWithId -> Ann Expr STWithId -> [Ann Name STWithId] actualContainingExpr :: SrcSpan -> Simple Traversal (Ann ValueBind STWithId) (Ann Expr STWithId) -- | Generates the expression that calls the local binding generateCall :: String -> [Ann Name STWithId] -> Ann Expr STWithId -- | Generates the local binding for the selected expression generateBind :: String -> [Ann Pattern STWithId] -> Ann Expr STWithId -> Ann ValueBind STWithId isValidBindingName :: String -> Bool module Language.Haskell.Tools.Refactor.RenameDefinition renameDefinition :: forall n. (NamedThing n, Data n) => Name -> String -> Ann Module (STWithNames n) -> RefactoredModule n renameDefinition' :: forall n. (NamedThing n, Data n) => RealSrcSpan -> String -> Ann Module (STWithNames n) -> RefactoredModule n module Language.Haskell.Tools.Refactor.GenerateExports -- | Creates an export list that imports standalone top-level definitions -- with all of their contained definitions generateExports :: NamedThing n => Ann Module (STWithNames n) -> RefactoredModule n -- | Get all the top-level definitions with flags that mark if they can -- contain other top-level definitions (classes and data declarations). getTopLevels :: Ann Module (STWithNames n) -> [(n, Bool)] -- | Get all the standalone top level definitions (their GHC unique names) -- in a module. You could also do getting all the names with a biplate -- reference and select the top-level ones, but this is more efficient. getTopLevelDeclName :: Decl (NodeInfo (SemanticInfo n) src) -> Maybe n -- | Create the export for a give name. createExports :: NamedThing n => [(n, Bool)] -> Ann ExportSpecList (STWithNames n) module Language.Haskell.Tools.Refactor.GenerateTypeSignature -- | Perform the refactoring on either local or top-level definition generateTypeSignature :: Simple Traversal (Ann Module STWithId) (AnnList Decl STWithId) -> Simple Traversal (Ann Module STWithId) (AnnList LocalBind STWithId) -> (forall d. (Show (d (NodeInfo STWithId SourceTemplate)), Data (d STWithId), Typeable d, BindingElem d) => AnnList d STWithId -> Maybe (Ann ValueBind STWithId)) -> Ann Module STWithId -> RefactoredModule Id generateTypeSignature' :: RealSrcSpan -> Ann Module STWithId -> RefactoredModule Id module Language.Haskell.Tools.Refactor.OrganizeImports organizeImports :: forall n. (NamedThing n, Data n) => Ann Module (STWithNames n) -> RefactoredModule n module Language.Haskell.Tools.Refactor type TemplateWithNames = NodeInfo (SemanticInfo Name) SourceTemplate type TemplateWithTypes = NodeInfo (SemanticInfo Id) SourceTemplate data RefactorCommand NoRefactor :: RefactorCommand OrganizeImports :: RefactorCommand GenerateExports :: RefactorCommand GenerateSignature :: RealSrcSpan -> RefactorCommand RenameDefinition :: RealSrcSpan -> String -> RefactorCommand ExtractBinding :: RealSrcSpan -> String -> RefactorCommand performCommand :: RefactorCommand -> Ann Module TemplateWithTypes -> Ghc (Either String (Ann Module TemplateWithTypes)) readCommand :: String -> String -> RefactorCommand readSrcSpan :: String -> String -> RealSrcSpan readSrcLoc :: String -> String -> RealSrcLoc onlineRefactor :: String -> FilePath -> String -> IO (Either String String) onlineASTView :: FilePath -> String -> IO (Either String String) performRefactor :: String -> String -> String -> IO (Either String String) astView :: String -> String -> IO String loadModule :: String -> String -> Ghc ModSummary parseTyped :: ModSummary -> Ghc (Ann Module TemplateWithTypes) parseRenamed :: ModSummary -> Ghc (Ann Module TemplateWithNames) -- | Should be only used for testing demoRefactor :: String -> String -> String -> IO () printSemaInfo :: (StructuralTraversable node, Outputable n) => node (NodeInfo (SemanticInfo n) src) -> Ghc (node (NodeInfo (SemanticInfo n) src)) instance GHC.Show.Show Language.Haskell.Tools.Refactor.RefactorCommand instance GHC.Generics.Generic SrcLoc.SrcSpan instance (GHC.Generics.Generic sema, GHC.Generics.Generic src) => GHC.Generics.Generic (Language.Haskell.Tools.AST.Ann.NodeInfo sema src) instance GHC.Generics.Generic Language.Haskell.Tools.AnnTrf.RangeTemplate.RangeTemplate instance GHC.Generics.Generic (Language.Haskell.Tools.AST.Ann.SemanticInfo n) instance GHC.Generics.Generic Language.Haskell.Tools.AnnTrf.SourceTemplate.SourceTemplate instance GHC.Generics.Generic Language.Haskell.Tools.AST.Ann.SpanInfo