ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Parser.Types

Synopsis

- data SumOrTuple b
  - = Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation]
  - | Tuple [Either (EpAnn EpaLocation) (LocatedA b)]
- pprSumOrTuple :: Outputable b => Boxity -> SumOrTuple b -> SDoc
- data PatBuilder p
  - = PatBuilderPat (Pat p)
  - | PatBuilderPar (LHsToken "(" p) (LocatedA (PatBuilder p)) (LHsToken ")" p)
  - | PatBuilderApp (LocatedA (PatBuilder p)) (LocatedA (PatBuilder p))
  - | PatBuilderAppType (LocatedA (PatBuilder p)) (LHsToken "@" p) (HsPatSigType GhcPs)
  - | PatBuilderOpApp (LocatedA (PatBuilder p)) (LocatedN RdrName) (LocatedA (PatBuilder p)) (EpAnn [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 Source #

Constructors

Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation] | Last two are the locations of the '|' before and after the payload
Tuple [Either (EpAnn EpaLocation) (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 (LHsToken "(" p) (LocatedA (PatBuilder p)) (LHsToken ")" p) |
PatBuilderApp (LocatedA (PatBuilder p)) (LocatedA (PatBuilder p)) |
PatBuilderAppType (LocatedA (PatBuilder p)) (LHsToken "@" p) (HsPatSigType GhcPs) |
PatBuilderOpApp (LocatedA (PatBuilder p)) (LocatedN RdrName) (LocatedA (PatBuilder p)) (EpAnn [AddEpAnn]) |
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) :: Type -> Type Source #

type InfixOp (PatBuilder GhcPs) Source #

type FunArg (PatBuilder GhcPs) Source #

Methods

ecpFromCmd' :: LHsCmd GhcPs -> PV (LocatedA (PatBuilder GhcPs)) Source #

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

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

mkHsLamPV :: SrcSpan -> (EpAnnComments -> MatchGroup GhcPs (LocatedA (PatBuilder GhcPs))) -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsLetPV :: SrcSpan -> LHsToken "let" GhcPs -> HsLocalBinds GhcPs -> LHsToken "in" GhcPs -> 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 -> LocatedL [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> EpAnnHsCase -> PV (LocatedA (PatBuilder GhcPs)) Source #

mkHsLamCasePV :: SrcSpan -> LamCaseVariant -> LocatedL [LMatch GhcPs (LocatedA (PatBuilder GhcPs))] -> [AddEpAnn] -> 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) -> LHsToken "@" GhcPs -> 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 -> LocatedL [LStmt GhcPs (LocatedA (PatBuilder GhcPs))] -> AnnList -> PV (LocatedA (PatBuilder GhcPs)) Source #

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

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

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

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

mkHsWildCardPV :: SrcSpan -> PV (Located (PatBuilder GhcPs)) Source #

mkHsTySigPV :: SrcSpanAnnA -> LocatedA (PatBuilder GhcPs) -> LHsType GhcPs -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) Source #

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

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

mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA (PatBuilder GhcPs) -> ([Fbind (PatBuilder GhcPs)], Maybe SrcSpan) -> [AddEpAnn] -> PV (LocatedA (PatBuilder GhcPs)) Source #

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

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

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

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

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

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

mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> [AddEpAnn] -> 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.PostProcess type Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnL
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)))] = SrcSpanAnnL
type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.PostProcess type Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) = SrcAnn NoEpAnns
type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.PostProcess type Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA
type Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) Source # |
Instance details Defined in GHC.Parser.PostProcess 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 -> SrcSpan -> 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 #