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

Safe Haskell | Ignore
Language | GHC2021

GHC.Parser.Types

Synopsis

- data SumOrTuple b
  - = Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation]
  - | 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)) [AddEpAnn]
  - | 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 #

Constructors

Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation] | 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)) [AddEpAnn] |
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)) #

mkHsProjUpdatePV :: SrcSpan -> Located [LocatedAn NoEpAnns (DotFieldOcc GhcPs)] -> LocatedA (PatBuilder GhcPs) -> Bool -> [AddEpAnn] -> 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 -> LocatedL [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnHsCase -> PV (LocatedA (PatBuilder GhcPs)) #

mkHsLamPV :: SrcSpan -> HsLamVariant -> LocatedL [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> [AddEpAnn] -> 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 -> LocatedL [LStmt GhcPs (LocatedA (PatBuilder GhcPs))] -> AnnList -> 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 -> [AddEpAnn] -> 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) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) #

mkHsNegAppPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) #

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

mkHsViewPatPV :: SrcSpan -> LHsExpr GhcPs -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) #

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

mkHsLazyPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) #

mkHsBangPatPV :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) #

mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> [AddEpAnn] -> 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)))] = SrcSpanAnnL
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)))] = SrcSpanAnnL
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 #