Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Module = Module {}
- data ModuleHeader
- data Import
- data Decls
- data Comments
- type Lines = [String]
- makeModule :: PState -> Located (HsModule GhcPs) -> Module
- moduleHeader :: Module -> ModuleHeader
- moduleImports :: Module -> [Located Import]
- moduleImportGroups :: Module -> [NonEmpty (Located Import)]
- moduleDecls :: Module -> Decls
- moduleComments :: Module -> Comments
- moduleLanguagePragmas :: Module -> [(RealSrcSpan, NonEmpty Text)]
- queryModule :: Typeable a => (a -> [b]) -> Module -> [b]
- groupByLine :: (a -> RealSrcSpan) -> [a] -> [NonEmpty a]
- canMergeImport :: Import -> Import -> Bool
- mergeModuleImport :: Located Import -> Located Import -> Located Import
- lookupAnnotation :: SrcSpan -> Module -> [AnnKeywordId]
- rawComments :: Comments -> [RealLocated AnnotationComment]
- rawImport :: Import -> ImportDecl GhcPs
- rawModuleAnnotations :: Module -> [(ApiAnnKey, [SrcSpan])]
- rawModuleDecls :: Decls -> [LHsDecl GhcPs]
- rawModuleExports :: ModuleHeader -> Maybe (Located [LIE GhcPs])
- rawModuleHaddocks :: ModuleHeader -> Maybe LHsDocString
- rawModuleName :: ModuleHeader -> Maybe (Located ModuleName)
Data types
Concrete module type
Module | |
|
Instances
Data Module Source # | |
Defined in Language.Haskell.Stylish.Module gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Module -> c Module # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Module # toConstr :: Module -> Constr # dataTypeOf :: Module -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Module) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module) # gmapT :: (forall b. Data b => b -> b) -> Module -> Module # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r # gmapQ :: (forall d. Data d => d -> u) -> Module -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Module -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Module -> m Module # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module # |
data ModuleHeader Source #
A module header is its name, exports and haddock docstring
Import declaration in module
makeModule :: PState -> Located (HsModule GhcPs) -> Module Source #
Create a module from GHC internal representations
Getters
moduleHeader :: Module -> ModuleHeader Source #
Get module header
moduleImportGroups :: Module -> [NonEmpty (Located Import)] Source #
Get groups of imports from module
moduleDecls :: Module -> Decls Source #
Get all declarations in module
moduleComments :: Module -> Comments Source #
Get comments in module
moduleLanguagePragmas :: Module -> [(RealSrcSpan, NonEmpty Text)] Source #
Get module language pragmas
queryModule :: Typeable a => (a -> [b]) -> Module -> [b] Source #
Query the module AST using f
groupByLine :: (a -> RealSrcSpan) -> [a] -> [NonEmpty a] Source #
Imports
canMergeImport :: Import -> Import -> Bool Source #
Returns true if the two import declarations can be merged
mergeModuleImport :: Located Import -> Located Import -> Located Import Source #
Merge two import declarations, keeping positions from the first
As alluded, this highlights an issue with merging imports. The GHC annotation comments aren't attached to any particular AST node. This means that right now, we're manually reconstructing the attachment. By merging two import declarations, we lose that mapping.
It's not really a big deal if we consider that people don't usually comment imports themselves. It _is_ however, systemic and it'd be better if we processed comments beforehand and attached them to all AST nodes in our own representation.
Annotations
lookupAnnotation :: SrcSpan -> Module -> [AnnKeywordId] Source #
Query for annotations associated with a SrcSpan
Internal API getters
rawComments :: Comments -> [RealLocated AnnotationComment] Source #
Getter for internal module comments representation
rawModuleAnnotations :: Module -> [(ApiAnnKey, [SrcSpan])] Source #
Getter for internal module annotation representation
rawModuleExports :: ModuleHeader -> Maybe (Located [LIE GhcPs]) Source #
Getter for internal module exports representation
rawModuleHaddocks :: ModuleHeader -> Maybe LHsDocString Source #
Getter for internal module haddocks representation
rawModuleName :: ModuleHeader -> Maybe (Located ModuleName) Source #
Getter for internal module name representation