| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
GHC.Parser.Annotation
Synopsis
- getAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> [RealSrcSpan]
- getAndRemoveAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> ([RealSrcSpan], ApiAnns)
- getAnnotationComments :: ApiAnns -> RealSrcSpan -> [RealLocated AnnotationComment]
- getAndRemoveAnnotationComments :: ApiAnns -> RealSrcSpan -> ([RealLocated AnnotationComment], ApiAnns)
- data ApiAnns = ApiAnns {}
- type ApiAnnKey = (RealSrcSpan, AnnKeywordId)
- data AnnKeywordId- = AnnAnyclass
- | AnnAs
- | AnnAt
- | AnnBang
- | AnnBackquote
- | AnnBy
- | AnnCase
- | AnnClass
- | AnnClose
- | AnnCloseB
- | AnnCloseBU
- | AnnCloseC
- | AnnCloseQ
- | AnnCloseQU
- | AnnCloseP
- | AnnCloseS
- | AnnColon
- | AnnComma
- | AnnCommaTuple
- | AnnDarrow
- | AnnDarrowU
- | AnnData
- | AnnDcolon
- | AnnDcolonU
- | AnnDefault
- | AnnDeriving
- | AnnDo
- | AnnDot
- | AnnDotdot
- | AnnElse
- | AnnEqual
- | AnnExport
- | AnnFamily
- | AnnForall
- | AnnForallU
- | AnnForeign
- | AnnFunId
- | AnnGroup
- | AnnHeader
- | AnnHiding
- | AnnIf
- | AnnImport
- | AnnIn
- | AnnInfix
- | AnnInstance
- | AnnLam
- | AnnLarrow
- | AnnLarrowU
- | AnnLet
- | AnnLollyU
- | AnnMdo
- | AnnMinus
- | AnnModule
- | AnnPercentOne
- | AnnNewtype
- | AnnName
- | AnnOf
- | AnnOpen
- | AnnOpenB
- | AnnOpenBU
- | AnnOpenC
- | AnnOpenE
- | AnnOpenEQ
- | AnnOpenEQU
- | AnnOpenP
- | AnnOpenS
- | AnnDollar
- | AnnDollarDollar
- | AnnPackageName
- | AnnPattern
- | AnnPercent
- | AnnProc
- | AnnQualified
- | AnnRarrow
- | AnnRarrowU
- | AnnRec
- | AnnRole
- | AnnSafe
- | AnnSemi
- | AnnSimpleQuote
- | AnnSignature
- | AnnStatic
- | AnnStock
- | AnnThen
- | AnnThTyQuote
- | AnnTilde
- | AnnType
- | AnnUnit
- | AnnUsing
- | AnnVal
- | AnnValStr
- | AnnVbar
- | AnnVia
- | AnnWhere
- | Annlarrowtail
- | AnnlarrowtailU
- | Annrarrowtail
- | AnnrarrowtailU
- | AnnLarrowtail
- | AnnLarrowtailU
- | AnnRarrowtail
- | AnnRarrowtailU
 
- data AddAnn = AddAnn AnnKeywordId SrcSpan
- mkParensApiAnn :: SrcSpan -> [AddAnn]
- data AnnotationComment
- data IsUnicodeSyntax
- unicodeAnn :: AnnKeywordId -> AnnKeywordId
- data HasE
- type LRdrName = Located RdrName
Documentation
getAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> [RealSrcSpan] #
getAndRemoveAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> ([RealSrcSpan], ApiAnns) #
getAndRemoveAnnotationComments :: ApiAnns -> RealSrcSpan -> ([RealLocated AnnotationComment], ApiAnns) #
Retrieve the comments allocated to the current SrcSpan, and
 remove them from the annotations
Constructors
| ApiAnns | |
type ApiAnnKey = (RealSrcSpan, AnnKeywordId) #
data AnnKeywordId #
API Annotations exist so that tools can perform source to source conversions of Haskell code. They are used to keep track of the various syntactic keywords that are not captured in the existing AST.
The annotations, together with original source comments are made
 available in the pm_annotationsParsedModuleOpt_KeepRawTokenStreamDynFlags
The wiki page describing this feature is https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations
Note: in general the names of these are taken from the corresponding token, unless otherwise noted See note [Api annotations] above for details of the usage
Constructors
Instances
Encapsulated call to addAnnotation, requiring only the SrcSpan of the AST construct the annotation belongs to; together with the AnnKeywordId, this is the key of the annotation map.
This type is useful for places in the parser where it is not yet
   known what SrcSpan an annotation should be added to.  The most
   common situation is when we are parsing a list: the annotations
   need to be associated with the AST element that *contains* the
   list, not the list itself.  AddAnn lets us defer adding the
   annotations until we finish parsing the list and are now parsing
   the enclosing element; we then apply the AddAnn to associate
   the annotations.  Another common situation is where a common fragment of
   the AST has been factored out but there is no separate AST node for
   this fragment (this occurs in class and data declarations). In this
   case, the annotation belongs to the parent data declaration.
The usual way an AddAnn is created is using the mj ("make jump")
   function, and then it can be discharged using the ams function.
Constructors
| AddAnn AnnKeywordId SrcSpan | 
mkParensApiAnn :: SrcSpan -> [AddAnn] #
data AnnotationComment #
Constructors
| AnnDocCommentNext String | something beginning '-- |' | 
| AnnDocCommentPrev String | something beginning '-- ^' | 
| AnnDocCommentNamed String | something beginning '-- $' | 
| AnnDocSection Int String | a section heading | 
| AnnDocOptions String | doc options (prune, ignore-exports, etc) | 
| AnnLineComment String | comment starting by "--" | 
| AnnBlockComment String | comment in {- -} | 
Instances
data IsUnicodeSyntax #
Certain tokens can have alternate representations when unicode syntax is
 enabled. This flag is attached to those tokens in the lexer so that the
 original source representation can be reproduced in the corresponding
 ApiAnnotation
Constructors
| UnicodeSyntax | |
| NormalSyntax | 
Instances
unicodeAnn :: AnnKeywordId -> AnnKeywordId #
Convert a normal annotation into its unicode equivalent one
Some template haskell tokens have two variants, one with an e the other
 not:
[| or [e| [|| or [e||
This type indicates whether the e is present or not.
Instances
| Data HasE # | |
| Defined in GHC.Parser.Annotation Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HasE -> c HasE Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HasE Source # toConstr :: HasE -> Constr Source # dataTypeOf :: HasE -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HasE) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HasE) Source # gmapT :: (forall b. Data b => b -> b) -> HasE -> HasE Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HasE -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HasE -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HasE -> m HasE Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HasE -> m HasE Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HasE -> m HasE Source # | |
| Show HasE # | |
| Eq HasE # | |
| Ord HasE # | |