ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Parser.Types

Synopsis

- data SumOrTuple b
  - = Sum ConTag Arity (LocatedA b) [EpToken "|"] [EpToken "|"]
  - | Tuple [Either (EpAnn Bool) (LocatedA b)]
- pprSumOrTuple :: Outputable b => Boxity -> SumOrTuple b -> SDoc
- data PatBuilder p
  - = PatBuilderPat (Pat p)
  - | PatBuilderPar (EpToken "(") (LocatedA (PatBuilder p)) (EpToken ")")
  - | PatBuilderApp (LocatedA (PatBuilder p)) (LocatedA (PatBuilder p))
  - | PatBuilderAppType (LocatedA (PatBuilder p)) (EpToken "@") (HsTyPat GhcPs)
  - | PatBuilderOpApp (LocatedA (PatBuilder p)) (LocatedN RdrName) (LocatedA (PatBuilder p)) ([EpToken "("], [EpToken ")"])
  - | PatBuilderVar (LocatedN RdrName)
  - | PatBuilderOverLit (HsOverLit GhcPs)
- data DataConBuilder
  - = PrefixDataConBuilder (OrdList (LHsType GhcPs)) (LocatedN RdrName)
  - | InfixDataConBuilder (LHsType GhcPs) (LocatedN RdrName) (LHsType GhcPs)
- data ExplicitNamespaceKeyword
  - = ExplicitTypeNamespace !(EpToken "type")
  - | ExplicitDataNamespace !(EpToken "data")

# Documentation

data SumOrTuple b #

Constructors

Sum ConTag Arity (LocatedA b) [EpToken "|"] [EpToken "|"] | Last two are the locations of the '|' before and after the payload
Tuple [Either (EpAnn Bool) (LocatedA b)] |

pprSumOrTuple :: Outputable b => Boxity -> SumOrTuple b -> SDoc #

data PatBuilder p #

See Note [Ambiguous syntactic categories] and Note [PatBuilder]

Constructors

PatBuilderPat (Pat p) |
PatBuilderPar (EpToken "(") (LocatedA (PatBuilder p)) (EpToken ")") |
PatBuilderApp (LocatedA (PatBuilder p)) (LocatedA (PatBuilder p)) |
PatBuilderAppType (LocatedA (PatBuilder p)) (EpToken "@") (HsTyPat GhcPs) |
PatBuilderOpApp (LocatedA (PatBuilder p)) (LocatedN RdrName) (LocatedA (PatBuilder p)) ([EpToken "("], [EpToken ")"]) |
PatBuilderVar (LocatedN RdrName) |
PatBuilderOverLit (HsOverLit GhcPs) |

#### Instances

Instances details

DisambECP (PatBuilder GhcPs) # |
Instance details Defined in GHC.Parser.PostProcess Associated Types
type Body (PatBuilder GhcPs) |
Instance details Defined in GHC.Parser.PostProcess type Body (PatBuilder GhcPs) = PatBuilder
type InfixOp (PatBuilder GhcPs) |
Instance details Defined in GHC.Parser.PostProcess type InfixOp (PatBuilder GhcPs) = RdrName
type FunArg (PatBuilder GhcPs) |
Instance details Defined in GHC.Parser.PostProcess type FunArg (PatBuilder GhcPs) = PatBuilder GhcPs
Methods ecpFromCmd' :: LHsCmd GhcPs -> PV (LocatedA (PatBuilder GhcPs)) # ecpFromExp' :: LHsExpr GhcPs -> PV (LocatedA (PatBuilder GhcPs)) # ecpFromPat' :: LPat GhcPs -> PV (LocatedA (PatBuilder GhcPs)) # mkHsProjUpdatePV :: SrcSpan -> Located (NonEmpty (LocatedAn NoEpAnns (DotFieldOcc GhcPs))) -> LocatedA (PatBuilder GhcPs) -> Bool -> Maybe (EpToken "=") -> PV (LHsRecProj GhcPs (LocatedA (PatBuilder GhcPs))) # mkHsLetPV :: SrcSpan -> EpToken "let" -> HsLocalBinds GhcPs -> EpToken "in" -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # superInfixOp :: (DisambInfixOp (InfixOp (PatBuilder GhcPs)) => PV (LocatedA (PatBuilder GhcPs))) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsOpAppPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> LocatedN (InfixOp (PatBuilder GhcPs)) -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsCasePV :: SrcSpan -> LHsExpr GhcPs -> LocatedLW [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnHsCase -> PV (LocatedA (PatBuilder GhcPs)) # mkHsLamPV :: SrcSpan -> HsLamVariant -> LocatedLW [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnLam -> PV (LocatedA (PatBuilder GhcPs)) # superFunArg :: (DisambECP (FunArg (PatBuilder GhcPs)) => PV (LocatedA (PatBuilder GhcPs))) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsAppPV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> LocatedA (FunArg (PatBuilder GhcPs)) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsAppTypePV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> EpToken "@" -> LHsType GhcPs -> PV (LocatedA (PatBuilder GhcPs)) # mkHsIfPV :: SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA (PatBuilder GhcPs) -> Bool -> LocatedA (PatBuilder GhcPs) -> AnnsIf -> PV (LocatedA (PatBuilder GhcPs)) # mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedLW [LStmt GhcPs (LocatedA (PatBuilder GhcPs))] -> EpaLocation -> EpaLocation -> PV (LocatedA (PatBuilder GhcPs)) # mkHsParPV :: SrcSpan -> EpToken "(" -> LocatedA (PatBuilder GhcPs) -> EpToken ")" -> PV (LocatedA (PatBuilder GhcPs)) # mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (PatBuilder GhcPs)) # mkHsLitPV :: Located (HsLit GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsOverLitPV :: LocatedAn a (HsOverLit GhcPs) -> PV (LocatedAn a (PatBuilder GhcPs)) # mkHsWildCardPV :: NoAnn a => SrcSpan -> PV (LocatedAn a (PatBuilder GhcPs)) # mkHsTySigPV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> LHsType GhcPs -> TokDcolon -> PV (LocatedA (PatBuilder GhcPs)) # mkHsExplicitListPV :: SrcSpan -> [LocatedA (PatBuilder GhcPs)] -> AnnList () -> PV (LocatedA (PatBuilder GhcPs)) # mkHsSplicePV :: Located (HsUntypedSplice GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA (PatBuilder GhcPs) -> ([Fbind (PatBuilder GhcPs)], Maybe SrcSpan) -> (Maybe (EpToken "{"), Maybe (EpToken "}")) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsNegAppPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "-" -> PV (LocatedA (PatBuilder GhcPs)) # mkHsSectionR_PV :: SrcSpan -> LocatedA (InfixOp (PatBuilder GhcPs)) -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsArrowPV :: SrcSpan -> ArrowParsingMode lhs (PatBuilder GhcPs) -> LocatedA lhs -> HsMultAnnOf (LocatedA (PatBuilder GhcPs)) GhcPs -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsMultPV :: EpToken "%" -> LocatedA (PatBuilder GhcPs) -> PV (TokRarrow -> HsMultAnnOf (LocatedA (PatBuilder GhcPs)) GhcPs) # mkHsForallPV :: SrcSpan -> HsForAllTelescope GhcPs -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # checkContextPV :: LocatedA (PatBuilder GhcPs) -> PV (LocatedC [LocatedA (PatBuilder GhcPs)]) # mkQualPV :: SrcSpan -> LocatedC [LocatedA (PatBuilder GhcPs)] -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> EpToken "@" -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsLazyPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "~" -> PV (LocatedA (PatBuilder GhcPs)) # mkHsBangPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "!" -> PV (LocatedA (PatBuilder GhcPs)) # mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> (EpaLocation, EpaLocation) -> PV (LocatedA (PatBuilder GhcPs)) # mkHsEmbTyPV :: SrcSpan -> EpToken "type" -> LHsType GhcPs -> PV (LocatedA (PatBuilder GhcPs)) # rejectPragmaPV :: LocatedA (PatBuilder GhcPs) -> PV () #
Outputable (PatBuilder GhcPs) # |
Instance details Defined in GHC.Parser.Types Methods ppr :: PatBuilder GhcPs -> SDoc #
type Body (PatBuilder GhcPs) # |
Instance details Defined in GHC.Parser.PostProcess type Body (PatBuilder GhcPs) = PatBuilder
type FunArg (PatBuilder GhcPs) # |
Instance details Defined in GHC.Parser.PostProcess type FunArg (PatBuilder GhcPs) = PatBuilder GhcPs
type InfixOp (PatBuilder GhcPs) # |
Instance details Defined in GHC.Parser.PostProcess type InfixOp (PatBuilder GhcPs) = RdrName
type Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] # |
Instance details Defined in GHC.Parser.Types type Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnLW
type Anno [LocatedA (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs)))] # |
Instance details Defined in GHC.Parser.Types type Anno [LocatedA (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnLW
type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) # |
Instance details Defined in GHC.Parser.Types type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) = EpAnnCO
type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) # |
Instance details Defined in GHC.Parser.Types type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA
type Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) # |
Instance details Defined in GHC.Parser.Types type Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA

data DataConBuilder #

An accumulator to build a prefix data constructor, e.g. when parsing `MkT A B C`, the accumulator will evolve as follows:

     1. PrefixDataConBuilder []        MkT
     2. PrefixDataConBuilder [A]       MkT
     3. PrefixDataConBuilder [A, B]    MkT
     4. PrefixDataConBuilder [A, B, C] MkT

There are two reasons we have a separate builder type instead of using `HsConDeclDetails GhcPs` directly:

1. It's faster, because `OrdList` gives us constant-time snoc.
2. Having a separate type helps ensure that we don't forget to finalize a `RecTy` into a `RecCon` (we do that in `dataConBuilderDetails`).

See Note [PatBuilder] for another builder type used in the parser. Here the technique is similar, but the motivation is different.

Constructors

PrefixDataConBuilder (OrdList (LHsType GhcPs)) (LocatedN RdrName) |
InfixDataConBuilder (LHsType GhcPs) (LocatedN RdrName) (LHsType GhcPs) |

#### Instances

Instances details

DisambTD DataConBuilder # |
Instance details Defined in GHC.Parser.PostProcess Methods mkHsAppTyHeadPV :: LHsType GhcPs -> PV (LocatedA DataConBuilder) # mkHsAppTyPV :: LocatedA DataConBuilder -> LHsType GhcPs -> PV (LocatedA DataConBuilder) # mkHsAppKindTyPV :: LocatedA DataConBuilder -> EpToken "@" -> LHsType GhcPs -> PV (LocatedA DataConBuilder) # mkHsOpTyPV :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA DataConBuilder) # mkUnpackednessPV :: Located UnpackednessPragma -> LocatedA DataConBuilder -> PV (LocatedA DataConBuilder) #
Outputable DataConBuilder # |
Instance details Defined in GHC.Parser.Types Methods ppr :: DataConBuilder -> SDoc #

data ExplicitNamespaceKeyword #

Constructors

ExplicitTypeNamespace !(EpToken "type") |
ExplicitDataNamespace !(EpToken "data") |