Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data RefactorCtx a = RefactorCtx {
- refModuleName :: Module
- refCtxImports :: [Ann ImportDecl a]
- runRefactor :: (a ~ STWithNames n, TemplateAnnot a) => Ann Module a -> (Ann Module a -> Refactor n (Ann Module a)) -> Ghc (Either String (Ann Module a))
- addGeneratedImports :: (TemplateAnnot a, Monad m) => ReaderT (RefactorCtx a) m (Ann Module a, [Name]) -> ReaderT (RefactorCtx a) m (Ann Module a)
- newtype RefactorT ann m ast = RefactorT {
- fromRefactorT :: WriterT [Name] (ReaderT (RefactorCtx ann) m) ast
- refactError :: String -> Refactor n a
- 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))
- referenceName' :: (Eq n, NamedThing n) => ([String] -> Name -> Ann nt (STWithNames n)) -> n -> Refactor n (Ann nt (STWithNames n))
- referenceBy :: TemplateAnnot a => ([String] -> Name -> Ann nt a) -> Name -> [Ann ImportDecl a] -> Ann nt a
- data NameClass
- classifyName :: Name -> Refactor n NameClass
- nameValid :: NameClass -> String -> Bool
- isIdStartChar :: Char -> Bool
- isOperatorChar :: Char -> Bool
Documentation
data RefactorCtx a Source #
The information a refactoring can use
RefactorCtx | |
|
Monad m => MonadReader (RefactorCtx ann) (RefactorT ann m) Source # | |
runRefactor :: (a ~ STWithNames n, TemplateAnnot a) => Ann Module a -> (Ann Module a -> Refactor n (Ann Module a)) -> Ghc (Either String (Ann Module a)) Source #
Performs the given refactoring, transforming it into a Ghc action
addGeneratedImports :: (TemplateAnnot a, Monad m) => ReaderT (RefactorCtx a) m (Ann Module a, [Name]) -> ReaderT (RefactorCtx a) m (Ann Module a) Source #
Adds the imports that bring names into scope that are needed by the refactoring
newtype RefactorT ann m ast Source #
Input and output information for the refactoring
RefactorT | |
|
MonadTrans (RefactorT ann) Source # | |
Monad m => MonadReader (RefactorCtx ann) (RefactorT ann m) Source # | |
Monad m => MonadWriter [Name] (RefactorT ann m) Source # | |
Monad m => Monad (RefactorT ann m) Source # | |
Functor m => Functor (RefactorT ann m) Source # | |
Applicative m => Applicative (RefactorT ann m) Source # | |
MonadIO m => MonadIO (RefactorT ann m) Source # | |
GhcMonad m => GhcMonad (RefactorT ann m) Source # | |
(Monad m, HasDynFlags m) => HasDynFlags (RefactorT ann m) Source # | |
ExceptionMonad m => ExceptionMonad (RefactorT ann m) Source # | |
refactError :: String -> Refactor n a Source #
type STWithNames n = NodeInfo (SemanticInfo n) SourceTemplate Source #
type RefactoredModule n = Refactor n (Ann Module (STWithNames n)) Source #
qualifiedName :: Name -> String Source #
referenceName :: (Eq n, NamedThing n) => n -> Refactor n (Ann Name (STWithNames n)) Source #
referenceOperator :: (Eq n, NamedThing n) => n -> Refactor n (Ann Operator (STWithNames n)) Source #
referenceName' :: (Eq n, NamedThing n) => ([String] -> Name -> Ann nt (STWithNames n)) -> n -> Refactor n (Ann nt (STWithNames n)) Source #
Create a name that references the definition. Generates an import if the definition is not yet imported.
referenceBy :: TemplateAnnot a => ([String] -> Name -> Ann nt a) -> Name -> [Ann ImportDecl a] -> Ann nt a Source #
Reference the name by the shortest suitable import
Different classes of definitions that have different kind of names.
Variable | Normal value definitions: functions, variables |
Ctor | Data constructors |
ValueOperator | Functions with operator-like names |
DataCtorOperator | Constructors with operator-like names |
SynonymOperator | Type definitions with operator-like names |
nameValid :: NameClass -> String -> Bool Source #
Check if a given name is valid for a given kind of definition
isIdStartChar :: Char -> Bool Source #
isOperatorChar :: Char -> Bool Source #
Orphan instances
GhcMonad m => GhcMonad (ExceptT s m) Source # | |
(GhcMonad m, Monoid s) => GhcMonad (WriterT s m) Source # | |
ExceptionMonad m => ExceptionMonad (ExceptT s m) Source # | |
(ExceptionMonad m, Monoid s) => ExceptionMonad (WriterT s m) Source # | |
GhcMonad m => GhcMonad (ReaderT * s m) Source # | |
ExceptionMonad m => ExceptionMonad (ReaderT * s m) Source # | |