stylish-haskell-0.12.2.0: Haskell code prettifier

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Stylish.Module

Contents

Synopsis

Data types

data Module Source #

Concrete module type

Instances
Data Module Source # 
Instance details

Defined in Language.Haskell.Stylish.Module

Methods

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

data Import Source #

Import declaration in module

Instances
Eq Import Source # 
Instance details

Defined in Language.Haskell.Stylish.Module

Methods

(==) :: Import -> Import -> Bool #

(/=) :: Import -> Import -> Bool #

Ord Import Source # 
Instance details

Defined in Language.Haskell.Stylish.Module

Outputable Import Source # 
Instance details

Defined in Language.Haskell.Stylish.Module

Methods

ppr :: Import -> SDoc #

pprPrec :: Rational -> Import -> SDoc #

data Decls Source #

Declarations in module

data Comments Source #

Comments associated with module

type Lines = [String] Source #

makeModule :: PState -> Located (HsModule GhcPs) -> Module Source #

Create a module from GHC internal representations

Getters

moduleHeader :: Module -> ModuleHeader Source #

Get module header

moduleImports :: Module -> [Located Import] Source #

Get module imports

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

rawImport :: Import -> ImportDecl GhcPs Source #

Getter for internal components in imports newtype

rawModuleAnnotations :: Module -> [(ApiAnnKey, [SrcSpan])] Source #

Getter for internal module annotation representation

rawModuleDecls :: Decls -> [LHsDecl GhcPs] Source #

Getter for internal module decls 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