Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
ghc-exactprint
is a library to manage manipulating Haskell
source files. There are four components.
Synopsis
- type Anns = Map AnnKey Annotation
- data Comment
- data Annotation = Ann {
- annEntryDelta :: !DeltaPos
- annPriorComments :: ![(Comment, DeltaPos)]
- annFollowingComments :: ![(Comment, DeltaPos)]
- annsDP :: ![(KeywordId, DeltaPos)]
- annSortKey :: !(Maybe [RealSrcSpan])
- annCapturedSpan :: !(Maybe AnnKey)
- data AnnKey = AnnKey RealSrcSpan AnnConName
- parseModule :: LibDir -> FilePath -> IO (ParseResult ParsedSource)
- module Language.Haskell.GHC.ExactPrint.Transform
- exactPrint :: ExactPrint ast => Located ast -> String
Relativising
type Anns = Map AnnKey Annotation Source #
This structure holds a complete set of annotations for an AST
A Haskell comment. The AnnKeywordId
is present if it has been converted
from an AnnKeywordId
because the annotation must be interleaved into the
stream and does not have a well-defined position
data Annotation Source #
Ann | |
|
Instances
Eq Annotation Source # | |
Defined in Language.Haskell.GHC.ExactPrint.Types (==) :: Annotation -> Annotation -> Bool # (/=) :: Annotation -> Annotation -> Bool # | |
Monad m => MonadState (Anns, Int) (TransformT m) Source # | |
Defined in Language.Haskell.GHC.ExactPrint.Transform |
For every Located a
, use the SrcSpan
and constructor name of
a as the key, to store the standard annotation.
These are used to maintain context in the AP and EP monads
Instances
Data AnnKey Source # | |
Defined in Language.Haskell.GHC.ExactPrint.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnKey -> c AnnKey # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnKey # toConstr :: AnnKey -> Constr # dataTypeOf :: AnnKey -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnKey) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnKey) # gmapT :: (forall b. Data b => b -> b) -> AnnKey -> AnnKey # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnKey -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnKey -> r # gmapQ :: (forall d. Data d => d -> u) -> AnnKey -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnKey -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey # | |
Show AnnKey Source # | |
Eq AnnKey Source # | |
Ord AnnKey Source # | |
Monad m => MonadState (Anns, Int) (TransformT m) Source # | |
Defined in Language.Haskell.GHC.ExactPrint.Transform |
Parsing
parseModule :: LibDir -> FilePath -> IO (ParseResult ParsedSource) Source #
This entry point will also work out which language extensions are required and perform CPP processing if necessary.
parseModule = parseModuleWithCpp defaultCppOptions
Note: ParsedSource
is a synonym for Located
(HsModule
GhcPs
)
Transformation
Printing
exactPrint :: ExactPrint ast => Located ast -> String Source #