Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Module = Located (HsModule GhcPs)
- newtype Comments = Comments [RealLocated EpaComment]
- type Lines = [String]
- moduleImportGroups :: Module -> [NonEmpty (LImportDecl GhcPs)]
- queryModule :: Typeable a => (a -> [b]) -> Module -> [b]
- groupByLine :: (a -> RealSrcSpan) -> [a] -> [NonEmpty a]
- canMergeImport :: ImportDecl GhcPs -> ImportDecl GhcPs -> Bool
- mergeModuleImport :: LImportDecl GhcPs -> LImportDecl GhcPs -> LImportDecl GhcPs
- importModuleName :: ImportDecl GhcPs -> String
- moduleLanguagePragmas :: Module -> [(RealSrcSpan, NonEmpty String)]
Data types
Getters
moduleImportGroups :: Module -> [NonEmpty (LImportDecl GhcPs)] Source #
Get groups of imports from module
queryModule :: Typeable a => (a -> [b]) -> Module -> [b] Source #
Query the module AST using f
groupByLine :: (a -> RealSrcSpan) -> [a] -> [NonEmpty a] Source #
Imports
canMergeImport :: ImportDecl GhcPs -> ImportDecl GhcPs -> Bool Source #
Returns true if the two import declarations can be merged
mergeModuleImport :: LImportDecl GhcPs -> LImportDecl GhcPs -> LImportDecl GhcPs 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.
importModuleName :: ImportDecl GhcPs -> String Source #
Pragmas
moduleLanguagePragmas :: Module -> [(RealSrcSpan, NonEmpty String)] Source #
Orphan instances
Eq RawPkgQual Source # | |
(==) :: RawPkgQual -> RawPkgQual -> Bool # (/=) :: RawPkgQual -> RawPkgQual -> Bool # |