ghc-exactprint-1.9.0.0: ExactPrint for GHC

Safe Haskell | None
Language | Haskell2010

Language.Haskell.GHC.ExactPrint.Lookup

Synopsis

- keywordToString :: AnnKeywordId -> String
- data AnnKeywordId
  - = AnnAnyclass
  - | AnnAs
  - | AnnBang
  - | AnnBackquote
  - | AnnBy
  - | AnnCase
  - | AnnCases
  - | AnnClass
  - | AnnClose
  - | AnnCloseB
  - | AnnCloseBU
  - | AnnCloseC
  - | AnnCloseQ
  - | AnnCloseQU
  - | AnnCloseP
  - | AnnClosePH
  - | 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
  - | AnnNewtype
  - | AnnName
  - | AnnOf
  - | AnnOpen
  - | AnnOpenB
  - | AnnOpenBU
  - | AnnOpenC
  - | AnnOpenE
  - | AnnOpenEQ
  - | AnnOpenEQU
  - | AnnOpenP
  - | AnnOpenS
  - | AnnOpenPH
  - | AnnDollar
  - | AnnDollarDollar
  - | AnnPackageName
  - | AnnPattern
  - | AnnPercent
  - | AnnPercentOne
  - | 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 Comment = Comment {
  - commentContents :: !String
  - commentLoc :: !NoCommentsLocation
  - commentPriorTok :: !RealSrcSpan
  - commentOrigin :: !(Maybe AnnKeywordId)
  }

# Documentation

keywordToString :: AnnKeywordId -> String #

Maps `AnnKeywordId` to the corresponding String representation. There is no specific mapping for the following constructors. `AnnOpen`, `AnnClose`, `AnnVal`, `AnnPackageName`, `AnnHeader`, `AnnFunId`, `AnnInfix`

data AnnKeywordId #

Exact print 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 otherwise captured in the AST.

The wiki page describing this feature is https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations

Note: in general the names of these are taken from the corresponding token, unless otherwise noted See Note [exact print annotations] above for details of the usage

Constructors

AnnAnyclass |
AnnAs |
AnnBang | `!`
AnnBackquote | '`'
AnnBy |
AnnCase | case or lambda case
AnnCases | lambda cases
AnnClass |
AnnClose | '#)' or '#-}' etc
AnnCloseB | '|)'
AnnCloseBU | '|)', unicode variant
AnnCloseC | '}'
AnnCloseQ | '|]'
AnnCloseQU | '|]', unicode variant
AnnCloseP | ')'
AnnClosePH | '#)'
AnnCloseS | ']'
AnnColon |
AnnComma | as a list separator
AnnCommaTuple | in a RdrName for a tuple
AnnDarrow | '=>'
AnnDarrowU | '=>', unicode variant
AnnData |
AnnDcolon | '::'
AnnDcolonU | '::', unicode variant
AnnDefault |
AnnDeriving |
AnnDo |
AnnDot | `.`
AnnDotdot | '..'
AnnElse |
AnnEqual |
AnnExport |
AnnFamily |
AnnForall |
AnnForallU | Unicode variant
AnnForeign |
AnnFunId | for function name in matches where there are multiple equations for the function.
AnnGroup |
AnnHeader | for CType
AnnHiding |
AnnIf |
AnnImport |
AnnIn |
AnnInfix | 'infix' or 'infixl' or 'infixr'
AnnInstance |
AnnLam |
AnnLarrow | '<-'
AnnLarrowU | '<-', unicode variant
AnnLet |
AnnLollyU | The `⊸` unicode arrow
AnnMdo |
AnnMinus | `-`
AnnModule |
AnnNewtype |
AnnName | where a name loses its location in the AST, this carries it
AnnOf |
AnnOpen | '{-# DEPRECATED' etc. Opening of pragmas where the capitalisation of the string can be changed by the user. The actual text used is stored in a `SourceText` on the relevant pragma item.
AnnOpenB | '(|'
AnnOpenBU | '(|', unicode variant
AnnOpenC | '{'
AnnOpenE | '[e|' or '[e||'
AnnOpenEQ | '[|'
AnnOpenEQU | '[|', unicode variant
AnnOpenP | '('
AnnOpenS | '['
AnnOpenPH | '(#'
AnnDollar | prefix `$` -- TemplateHaskell
AnnDollarDollar | prefix `$$` -- TemplateHaskell
AnnPackageName |
AnnPattern |
AnnPercent | `%` -- for HsExplicitMult
AnnPercentOne | '%1' -- for HsLinearArrow
AnnProc |
AnnQualified |
AnnRarrow | `->`
AnnRarrowU | `->`, unicode variant
AnnRec |
AnnRole |
AnnSafe |
AnnSemi | ';'
AnnSimpleQuote | '''
AnnSignature |
AnnStatic | `static`
AnnStock |
AnnThen |
AnnThTyQuote | double '''
AnnTilde | `~`
AnnType |
AnnUnit | `()` for types
AnnUsing |
AnnVal | e.g. INTEGER
AnnValStr | String value, will need quotes when output
AnnVbar | '|'
AnnVia | `via`
AnnWhere |
Annlarrowtail | `-<`
AnnlarrowtailU | `-<`, unicode variant
Annrarrowtail | `->`
AnnrarrowtailU | `->`, unicode variant
AnnLarrowtail | `-<<`
AnnLarrowtailU | `-<<`, unicode variant
AnnRarrowtail | `>>-`
AnnRarrowtailU | `>>-`, unicode variant

#### Instances

Instances details

NoAnn AnnKeywordId |
Instance details Defined in GHC.Parser.Annotation Methods noAnn :: AnnKeywordId #
Outputable AnnKeywordId |
Instance details Defined in GHC.Parser.Annotation Methods ppr :: AnnKeywordId -> SDoc #
Data AnnKeywordId |

Instance details

Defined in GHC.Parser.Annotation

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnKeywordId #

toConstr :: AnnKeywordId -> Constr #

dataTypeOf :: AnnKeywordId -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnKeywordId) #

gmapT :: (forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r #

gmapQ :: (forall d. Data d => d -> u) -> AnnKeywordId -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId #

Show AnnKeywordId |
Instance details Defined in GHC.Parser.Annotation Methods showsPrec :: Int -> AnnKeywordId -> ShowS # show :: AnnKeywordId -> String # showList :: [AnnKeywordId] -> ShowS #
Eq AnnKeywordId |
Instance details Defined in GHC.Parser.Annotation Methods (==) :: AnnKeywordId -> AnnKeywordId -> Bool # (/=) :: AnnKeywordId -> AnnKeywordId -> Bool #
Ord AnnKeywordId |

Instance details

Defined in GHC.Parser.Annotation

Methods

compare :: AnnKeywordId -> AnnKeywordId -> Ordering #

(<) :: AnnKeywordId -> AnnKeywordId -> Bool #

(<=) :: AnnKeywordId -> AnnKeywordId -> Bool #

(>) :: AnnKeywordId -> AnnKeywordId -> Bool #

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

max :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId #

min :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId #

data Comment #

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

Constructors

Comment |

Fields

- commentContents :: !String

  The contents of the comment including separators

- commentLoc :: !NoCommentsLocation
- commentPriorTok :: !RealSrcSpan
- commentOrigin :: !(Maybe AnnKeywordId)

  We sometimes turn syntax into comments in order to process them properly.

#### Instances

Instances details

Outputable Comment # |
Instance details Defined in Language.Haskell.GHC.ExactPrint.Types Methods ppr :: Comment -> SDoc #
Data Comment # |

Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Comment -> c Comment #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Comment #

toConstr :: Comment -> Constr #

dataTypeOf :: Comment -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Comment) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comment) #

gmapT :: (forall b. Data b => b -> b) -> Comment -> Comment #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r #

gmapQ :: (forall d. Data d => d -> u) -> Comment -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Comment -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Comment -> m Comment #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment #

Show Comment # |
Instance details Defined in Language.Haskell.GHC.ExactPrint.Types Methods showsPrec :: Int -> Comment -> ShowS # show :: Comment -> String # showList :: [Comment] -> ShowS #
Eq Comment # |
Instance details Defined in Language.Haskell.GHC.ExactPrint.Types Methods (==) :: Comment -> Comment -> Bool # (/=) :: Comment -> Comment -> Bool #
Ord Comment # |
Instance details Defined in Language.Haskell.GHC.ExactPrint.Types Methods compare :: Comment -> Comment -> Ordering # (<) :: Comment -> Comment -> Bool # (<=) :: Comment -> Comment -> Bool # (>) :: Comment -> Comment -> Bool # (>=) :: Comment -> Comment -> Bool # max :: Comment -> Comment -> Comment # min :: Comment -> Comment -> Comment #