ghc-lib-parser-9.12.2.20250421: 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)

# Documentation

data SumOrTuple b Source #

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 Source #

data PatBuilder p Source #

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) Source # |

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)) Source #

ecpFromExp' :: LHsExpr GhcPs -> PV (LocatedA (PatBuilder GhcPs)) Source #

ecpFromPat' :: LPat GhcPs -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsProjUpdatePV :: SrcSpan -> Located [LocatedAn NoEpAnns (DotFieldOcc GhcPs)] -> LocatedA (PatBuilder GhcPs) -> Bool -> Maybe (EpToken "=") -> PV (LHsRecProj GhcPs (LocatedA (PatBuilder GhcPs))) Source #

mkHsLetPV :: SrcSpan -> EpToken "let" -> HsLocalBinds GhcPs -> EpToken "in" -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

superInfixOp :: (DisambInfixOp (InfixOp (PatBuilder GhcPs)) => PV (LocatedA (PatBuilder GhcPs))) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsOpAppPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> LocatedN (InfixOp (PatBuilder GhcPs)) -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsCasePV :: SrcSpan -> LHsExpr GhcPs -> LocatedLW [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnHsCase -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsLamPV :: SrcSpan -> HsLamVariant -> LocatedLW [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnLam -> PV (LocatedA (PatBuilder GhcPs)) Source #

superFunArg :: (DisambECP (FunArg (PatBuilder GhcPs)) => PV (LocatedA (PatBuilder GhcPs))) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsAppPV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> LocatedA (FunArg (PatBuilder GhcPs)) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsAppTypePV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> EpToken "@" -> LHsType GhcPs -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsIfPV :: SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA (PatBuilder GhcPs) -> Bool -> LocatedA (PatBuilder GhcPs) -> AnnsIf -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedLW [LStmt GhcPs (LocatedA (PatBuilder GhcPs))] -> EpaLocation -> EpaLocation -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsParPV :: SrcSpan -> EpToken "(" -> LocatedA (PatBuilder GhcPs) -> EpToken ")" -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsLitPV :: Located (HsLit GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsOverLitPV :: LocatedAn a (HsOverLit GhcPs) -> PV (LocatedAn a (PatBuilder GhcPs)) Source #

mkHsWildCardPV :: NoAnn a => SrcSpan -> PV (LocatedAn a (PatBuilder GhcPs)) Source #

mkHsTySigPV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> LHsType GhcPs -> TokDcolon -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsExplicitListPV :: SrcSpan -> [LocatedA (PatBuilder GhcPs)] -> AnnList () -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsSplicePV :: Located (HsUntypedSplice GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA (PatBuilder GhcPs) -> ([Fbind (PatBuilder GhcPs)], Maybe SrcSpan) -> (Maybe (EpToken "{"), Maybe (EpToken "}")) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsNegAppPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "-" -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsSectionR_PV :: SrcSpan -> LocatedA (InfixOp (PatBuilder GhcPs)) -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsArrowPV :: SrcSpan -> ArrowParsingMode lhs (PatBuilder GhcPs) -> LocatedA lhs -> HsArrowOf (LocatedA (PatBuilder GhcPs)) GhcPs -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsMultPV :: EpToken "%" -> LocatedA (PatBuilder GhcPs) -> PV (TokRarrow -> HsArrowOf (LocatedA (PatBuilder GhcPs)) GhcPs) Source #

mkHsForallPV :: SrcSpan -> HsForAllTelescope GhcPs -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

checkContextPV :: LocatedA (PatBuilder GhcPs) -> PV (LocatedC [LocatedA (PatBuilder GhcPs)]) Source #

mkQualPV :: SrcSpan -> LocatedC [LocatedA (PatBuilder GhcPs)] -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> EpToken "@" -> LocatedA (PatBuilder GhcPs) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsLazyPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "~" -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsBangPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> EpToken "!" -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> (EpaLocation, EpaLocation) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsEmbTyPV :: SrcSpan -> EpToken "type" -> LHsType GhcPs -> PV (LocatedA (PatBuilder GhcPs)) Source #

rejectPragmaPV :: LocatedA (PatBuilder GhcPs) -> PV () Source #

Outputable (PatBuilder GhcPs) Source # |
Instance details Defined in GHC.Parser.Types Methods ppr :: PatBuilder GhcPs -> SDoc Source #
type Body (PatBuilder GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess type Body (PatBuilder GhcPs) = PatBuilder
type FunArg (PatBuilder GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess type FunArg (PatBuilder GhcPs) = PatBuilder GhcPs
type InfixOp (PatBuilder GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess type InfixOp (PatBuilder GhcPs) = RdrName
type Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] Source # |
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)))] Source # |
Instance details Defined in GHC.Parser.Types type Anno [LocatedA (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnLW
type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.Types type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) = EpAnnCO
type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.Types type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA
type Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.Types type Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA

data DataConBuilder Source #

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 Source # |

Instance details

Defined in GHC.Parser.PostProcess

Methods

mkHsAppTyHeadPV :: LHsType GhcPs -> PV (LocatedA DataConBuilder) Source #

mkHsAppTyPV :: LocatedA DataConBuilder -> LHsType GhcPs -> PV (LocatedA DataConBuilder) Source #

mkHsAppKindTyPV :: LocatedA DataConBuilder -> EpToken "@" -> LHsType GhcPs -> PV (LocatedA DataConBuilder) Source #

mkHsOpTyPV :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA DataConBuilder) Source #

mkUnpackednessPV :: Located UnpackednessPragma -> LocatedA DataConBuilder -> PV (LocatedA DataConBuilder) Source #

Outputable DataConBuilder Source # |
Instance details Defined in GHC.Parser.Types Methods ppr :: DataConBuilder -> SDoc Source #