GHC.Parser.PostProcess

ghc-9.2.8: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Parser.PostProcess

Synopsis

- mkRdrGetField :: SrcSpanAnnA -> LHsExpr GhcPs -> Located (HsFieldLabel GhcPs) -> EpAnnCO -> LHsExpr GhcPs
- mkRdrProjection :: NonEmpty (Located (HsFieldLabel GhcPs)) -> EpAnn AnnProjection -> HsExpr GhcPs
- type Fbind b = Either (LHsRecField GhcPs (LocatedA b)) (LHsRecProj GhcPs (LocatedA b))
- mkHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
- mkHsIntegral :: IntegralLit -> HsOverLit GhcPs
- mkHsFractional :: FractionalLit -> HsOverLit GhcPs
- mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs
- mkHsDo :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs
- mkSpliceDecl :: LHsExpr GhcPs -> P (LHsDecl GhcPs)
- mkRoleAnnotDecl :: SrcSpan -> LocatedN RdrName -> [Located (Maybe FastString)] -> [AddEpAnn] -> P (LRoleAnnotDecl GhcPs)
- mkClassDecl :: SrcSpan -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs) -> Located (a, [LHsFunDep GhcPs]) -> OrdList (LHsDecl GhcPs) -> LayoutInfo -> [AddEpAnn] -> P (LTyClDecl GhcPs)
- mkTyData :: SrcSpan -> NewOrData -> Maybe (LocatedP CType) -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs) -> Maybe (LHsKind GhcPs) -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] -> P (LTyClDecl GhcPs)
- mkDataFamInst :: SrcSpan -> NewOrData -> Maybe (LocatedP CType) -> (Maybe (LHsContext GhcPs), HsOuterFamEqnTyVarBndrs GhcPs, LHsType GhcPs) -> Maybe (LHsKind GhcPs) -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] -> P (LInstDecl GhcPs)
- mkTySynonym :: SrcSpan -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] -> P (LTyClDecl GhcPs)
- mkTyFamInstEqn :: SrcSpan -> HsOuterFamEqnTyVarBndrs GhcPs -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs)
- mkStandaloneKindSig :: SrcSpan -> Located [LocatedN RdrName] -> LHsSigType GhcPs -> [AddEpAnn] -> P (LStandaloneKindSig GhcPs)
- mkTyFamInst :: SrcSpan -> TyFamInstEqn GhcPs -> [AddEpAnn] -> P (LInstDecl GhcPs)
- mkFamDecl :: SrcSpan -> FamilyInfo GhcPs -> TopLevelFlag -> LHsType GhcPs -> Located (FamilyResultSig GhcPs) -> Maybe (LInjectivityAnn GhcPs) -> [AddEpAnn] -> P (LTyClDecl GhcPs)
- mkInlinePragma :: SourceText -> (InlineSpec, RuleMatchInfo) -> Maybe Activation -> InlinePragma
- mkPatSynMatchGroup :: LocatedN RdrName -> LocatedL (OrdList (LHsDecl GhcPs)) -> P (MatchGroup GhcPs (LHsExpr GhcPs))
- mkRecConstrOrUpdate :: Bool -> LHsExpr GhcPs -> SrcSpan -> ([Fbind (HsExpr GhcPs)], Maybe SrcSpan) -> EpAnn [AddEpAnn] -> PV (HsExpr GhcPs)
- mkTyClD :: LTyClDecl (GhcPass p) -> LHsDecl (GhcPass p)
- mkInstD :: LInstDecl (GhcPass p) -> LHsDecl (GhcPass p)
- mkRdrRecordCon :: LocatedN RdrName -> HsRecordBinds GhcPs -> EpAnn [AddEpAnn] -> HsExpr GhcPs
- mkRdrRecordUpd :: Bool -> LHsExpr GhcPs -> [Fbind (HsExpr GhcPs)] -> EpAnn [AddEpAnn] -> PV (HsExpr GhcPs)
- setRdrNameSpace :: RdrName -> NameSpace -> RdrName
- fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P (LHsTyVarBndr () GhcPs)
- fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P [LHsTyVarBndr () GhcPs]
- annBinds :: AddEpAnn -> EpAnnComments -> HsLocalBinds GhcPs -> (HsLocalBinds GhcPs, Maybe EpAnnComments)
- cvBindGroup :: OrdList (LHsDecl GhcPs) -> P (HsValBinds GhcPs)
- cvBindsAndSigs :: OrdList (LHsDecl GhcPs) -> P (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs], [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs])
- cvTopDecls :: OrdList (LHsDecl GhcPs) -> [LHsDecl GhcPs]
- placeHolderPunRhs :: DisambECP b => PV (LocatedA b)
- mkImport :: Located CCallConv -> Located Safety -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs)
- parseCImport :: Located CCallConv -> Located Safety -> FastString -> String -> Located SourceText -> Maybe ForeignImport
- mkExport :: Located CCallConv -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs)
- mkExtName :: RdrName -> CLabelString
- mkGadtDecl :: SrcSpan -> [LocatedN RdrName] -> LHsSigType GhcPs -> [AddEpAnn] -> P (LConDecl GhcPs)
- mkConDeclH98 :: EpAnn [AddEpAnn] -> LocatedN RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs
- checkImportDecl :: Maybe EpaLocation -> Maybe EpaLocation -> P ()
- checkExpBlockArguments :: LHsExpr GhcPs -> PV ()
- checkCmdBlockArguments :: LHsCmd GhcPs -> PV ()
- checkPrecP :: Located (SourceText, Int) -> Located (OrdList (LocatedN RdrName)) -> P ()
- checkContext :: LHsType GhcPs -> P (LHsContext GhcPs)
- checkPattern :: LocatedA (PatBuilder GhcPs) -> P (LPat GhcPs)
- checkPattern_hints :: [Hint] -> PV (LocatedA (PatBuilder GhcPs)) -> P (LPat GhcPs)
- checkMonadComp :: PV (HsStmtContext GhcRn)
- checkValDef :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> Maybe (AddEpAnn, LHsType GhcPs) -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs)
- checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName)
- type LRuleTyTmVar = Located RuleTyTmVar
- data RuleTyTmVar = RuleTyTmVar (EpAnn [AddEpAnn]) (LocatedN RdrName) (Maybe (LHsType GhcPs))
- mkRuleBndrs :: [LRuleTyTmVar] -> [LRuleBndr GhcPs]
- mkRuleTyVarBndrs :: [LRuleTyTmVar] -> [LHsTyVarBndr () GhcPs]
- checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P ()
- checkRecordSyntax :: (MonadP m, Outputable a) => LocatedA a -> m (LocatedA a)
- checkEmptyGADTs :: Located ([AddEpAnn], [LConDecl GhcPs]) -> P (Located ([AddEpAnn], [LConDecl GhcPs]))
- addFatalError :: MonadP m => PsError -> m a
- hintBangPat :: SrcSpan -> Pat GhcPs -> PV ()
- mkBangTy :: EpAnn [AddEpAnn] -> SrcStrictness -> LHsType GhcPs -> HsType GhcPs
- data UnpackednessPragma = UnpackednessPragma [AddEpAnn] SourceText SrcUnpackedness
- mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> HsArrow GhcPs
- data ImpExpSubSpec
  - = ImpExpAbs
  - | ImpExpAll
  - | ImpExpList [LocatedA ImpExpQcSpec]
  - | ImpExpAllWith [LocatedA ImpExpQcSpec]
- data ImpExpQcSpec
  - = ImpExpQcName (LocatedN RdrName)
  - | ImpExpQcType EpaLocation (LocatedN RdrName)
  - | ImpExpQcWildcard
- mkModuleImpExp :: [AddEpAnn] -> LocatedA ImpExpQcSpec -> ImpExpSubSpec -> P (IE GhcPs)
- mkTypeImpExp :: LocatedN RdrName -> P (LocatedN RdrName)
- mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec)
- checkImportSpec :: LocatedL [LIE GhcPs] -> P (LocatedL [LIE GhcPs])
- starSym :: Bool -> String
- warnStarIsType :: SrcSpan -> P ()
- warnPrepositiveQualifiedModule :: SrcSpan -> P ()
- failOpFewArgs :: MonadP m => LocatedN RdrName -> m a
- failOpNotEnabledImportQualifiedPost :: SrcSpan -> P ()
- failOpImportQualifiedTwice :: SrcSpan -> P ()
- data SumOrTuple b
  - = Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation]
  - | Tuple [Either (EpAnn EpaLocation) (LocatedA b)]
- data PV a
- runPV :: PV a -> P a
- newtype ECP = ECP {
  - unECP :: forall b. DisambECP b => PV (LocatedA b)
  }
- class DisambInfixOp b where
  - mkHsVarOpPV :: LocatedN RdrName -> PV (LocatedN b)
  - mkHsConOpPV :: LocatedN RdrName -> PV (LocatedN b)
  - mkHsInfixHolePV :: SrcSpan -> (EpAnnComments -> EpAnn EpAnnUnboundVar) -> PV (Located b)
- class (b ~ Body b GhcPs, AnnoBody b) => DisambECP b where
  - type Body b :: Type -> Type
  - type InfixOp b
  - type FunArg b
  - ecpFromCmd' :: LHsCmd GhcPs -> PV (LocatedA b)
  - ecpFromExp' :: LHsExpr GhcPs -> PV (LocatedA b)
  - mkHsProjUpdatePV :: SrcSpan -> Located [Located (HsFieldLabel GhcPs)] -> LocatedA b -> Bool -> [AddEpAnn] -> PV (LHsRecProj GhcPs (LocatedA b))
  - mkHsLamPV :: SrcSpan -> (EpAnnComments -> MatchGroup GhcPs (LocatedA b)) -> PV (LocatedA b)
  - mkHsLetPV :: SrcSpan -> HsLocalBinds GhcPs -> LocatedA b -> AnnsLet -> PV (LocatedA b)
  - superInfixOp :: (DisambInfixOp (InfixOp b) => PV (LocatedA b)) -> PV (LocatedA b)
  - mkHsOpAppPV :: SrcSpan -> LocatedA b -> LocatedN (InfixOp b) -> LocatedA b -> PV (LocatedA b)
  - mkHsCasePV :: SrcSpan -> LHsExpr GhcPs -> LocatedL [LMatch GhcPs (LocatedA b)] -> EpAnnHsCase -> PV (LocatedA b)
  - mkHsLamCasePV :: SrcSpan -> LocatedL [LMatch GhcPs (LocatedA b)] -> [AddEpAnn] -> PV (LocatedA b)
  - superFunArg :: (DisambECP (FunArg b) => PV (LocatedA b)) -> PV (LocatedA b)
  - mkHsAppPV :: SrcSpanAnnA -> LocatedA b -> LocatedA (FunArg b) -> PV (LocatedA b)
  - mkHsAppTypePV :: SrcSpanAnnA -> LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b)
  - mkHsIfPV :: SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA b -> Bool -> LocatedA b -> AnnsIf -> PV (LocatedA b)
  - mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedL [LStmt GhcPs (LocatedA b)] -> AnnList -> PV (LocatedA b)
  - mkHsParPV :: SrcSpan -> LocatedA b -> AnnParen -> PV (LocatedA b)
  - mkHsVarPV :: LocatedN RdrName -> PV (LocatedA b)
  - mkHsLitPV :: Located (HsLit GhcPs) -> PV (Located b)
  - mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located b)
  - mkHsWildCardPV :: SrcSpan -> PV (Located b)
  - mkHsTySigPV :: SrcSpanAnnA -> LocatedA b -> LHsType GhcPs -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsExplicitListPV :: SrcSpan -> [LocatedA b] -> AnnList -> PV (LocatedA b)
  - mkHsSplicePV :: Located (HsSplice GhcPs) -> PV (Located b)
  - mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA b -> ([Fbind b], Maybe SrcSpan) -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsNegAppPV :: SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsSectionR_PV :: SrcSpan -> LocatedA (InfixOp b) -> LocatedA b -> PV (Located b)
  - mkHsViewPatPV :: SrcSpan -> LHsExpr GhcPs -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsLazyPatPV :: SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b)
  - mkHsBangPatPV :: SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b)
  - mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> [AddEpAnn] -> PV (LocatedA b)
  - rejectPragmaPV :: LocatedA b -> PV ()
- ecpFromExp :: LHsExpr GhcPs -> ECP
- ecpFromCmd :: LHsCmd GhcPs -> ECP
- data PatBuilder p
- class DisambTD b where
  - mkHsAppTyHeadPV :: LHsType GhcPs -> PV (LocatedA b)
  - mkHsAppTyPV :: LocatedA b -> LHsType GhcPs -> PV (LocatedA b)
  - mkHsAppKindTyPV :: LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b)
  - mkHsOpTyPV :: LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA b)
  - mkUnpackednessPV :: Located UnpackednessPragma -> LocatedA b -> PV (LocatedA b)
- addUnpackednessP :: MonadP m => Located UnpackednessPragma -> LHsType GhcPs -> m (LHsType GhcPs)
- dataConBuilderCon :: DataConBuilder -> LocatedN RdrName
- dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs

# Documentation

mkRdrGetField :: SrcSpanAnnA -> LHsExpr GhcPs -> Located (HsFieldLabel GhcPs) -> EpAnnCO -> LHsExpr GhcPs Source #

mkRdrProjection :: NonEmpty (Located (HsFieldLabel GhcPs)) -> EpAnn AnnProjection -> HsExpr GhcPs Source #

type Fbind b = Either (LHsRecField GhcPs (LocatedA b)) (LHsRecProj GhcPs (LocatedA b)) Source #

mkHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs Source #

A useful function for building `OpApps`. The operator is always a variable, and we don't know the fixity yet.

mkHsIntegral :: IntegralLit -> HsOverLit GhcPs Source #

mkHsFractional :: FractionalLit -> HsOverLit GhcPs Source #

mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs Source #

mkHsDo :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs Source #

mkSpliceDecl :: LHsExpr GhcPs -> P (LHsDecl GhcPs) Source #

mkRoleAnnotDecl :: SrcSpan -> LocatedN RdrName -> [Located (Maybe FastString)] -> [AddEpAnn] -> P (LRoleAnnotDecl GhcPs) Source #

mkClassDecl :: SrcSpan -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs) -> Located (a, [LHsFunDep GhcPs]) -> OrdList (LHsDecl GhcPs) -> LayoutInfo -> [AddEpAnn] -> P (LTyClDecl GhcPs) Source #

mkTyData :: SrcSpan -> NewOrData -> Maybe (LocatedP CType) -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs) -> Maybe (LHsKind GhcPs) -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] -> P (LTyClDecl GhcPs) Source #

mkDataFamInst :: SrcSpan -> NewOrData -> Maybe (LocatedP CType) -> (Maybe (LHsContext GhcPs), HsOuterFamEqnTyVarBndrs GhcPs, LHsType GhcPs) -> Maybe (LHsKind GhcPs) -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] -> P (LInstDecl GhcPs) Source #

mkTySynonym :: SrcSpan -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] -> P (LTyClDecl GhcPs) Source #

mkTyFamInstEqn :: SrcSpan -> HsOuterFamEqnTyVarBndrs GhcPs -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] -> P (LTyFamInstEqn GhcPs) Source #

mkStandaloneKindSig :: SrcSpan -> Located [LocatedN RdrName] -> LHsSigType GhcPs -> [AddEpAnn] -> P (LStandaloneKindSig GhcPs) Source #

mkTyFamInst :: SrcSpan -> TyFamInstEqn GhcPs -> [AddEpAnn] -> P (LInstDecl GhcPs) Source #

mkFamDecl :: SrcSpan -> FamilyInfo GhcPs -> TopLevelFlag -> LHsType GhcPs -> Located (FamilyResultSig GhcPs) -> Maybe (LInjectivityAnn GhcPs) -> [AddEpAnn] -> P (LTyClDecl GhcPs) Source #

mkInlinePragma :: SourceText -> (InlineSpec, RuleMatchInfo) -> Maybe Activation -> InlinePragma Source #

mkPatSynMatchGroup :: LocatedN RdrName -> LocatedL (OrdList (LHsDecl GhcPs)) -> P (MatchGroup GhcPs (LHsExpr GhcPs)) Source #

mkRecConstrOrUpdate :: Bool -> LHsExpr GhcPs -> SrcSpan -> ([Fbind (HsExpr GhcPs)], Maybe SrcSpan) -> EpAnn [AddEpAnn] -> PV (HsExpr GhcPs) Source #

mkTyClD :: LTyClDecl (GhcPass p) -> LHsDecl (GhcPass p) Source #

mkClassDecl builds a RdrClassDecl, filling in the names for tycon and datacon by deriving them from the name of the class. We fill in the names for the tycon and datacon corresponding to the class, by deriving them from the name of the class itself. This saves recording the names in the interface file (which would be equally good).

mkInstD :: LInstDecl (GhcPass p) -> LHsDecl (GhcPass p) Source #

mkRdrRecordCon :: LocatedN RdrName -> HsRecordBinds GhcPs -> EpAnn [AddEpAnn] -> HsExpr GhcPs Source #

mkRdrRecordUpd :: Bool -> LHsExpr GhcPs -> [Fbind (HsExpr GhcPs)] -> EpAnn [AddEpAnn] -> PV (HsExpr GhcPs) Source #

setRdrNameSpace :: RdrName -> NameSpace -> RdrName Source #

This rather gruesome function is used mainly by the parser. When parsing:

    data T a = T | T1 Int

we parse the data constructors as types because of parser ambiguities, so then we need to change the type constr to a data constr

The exact-name case can occur when parsing:

    data [] a = [] | a : [a]

For the exact-name case we return an original name.

fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P (LHsTyVarBndr () GhcPs) Source #

Converts `LHsTyVarBndr` annotated with its `Specificity` to one without annotations. Only accepts specified variables, and errors if the provided binder has an `InferredSpec` annotation.

fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P [LHsTyVarBndr () GhcPs] Source #

Converts a list of `LHsTyVarBndr`s annotated with their `Specificity` to binders without annotations. Only accepts specified variables, and errors if any of the provided binders has an `InferredSpec` annotation.

annBinds :: AddEpAnn -> EpAnnComments -> HsLocalBinds GhcPs -> (HsLocalBinds GhcPs, Maybe EpAnnComments) Source #

Add the annotation for a 'where' keyword to existing `HsLocalBinds`

cvBindGroup :: OrdList (LHsDecl GhcPs) -> P (HsValBinds GhcPs) Source #

cvBindsAndSigs :: OrdList (LHsDecl GhcPs) -> P (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs], [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs]) Source #

cvTopDecls :: OrdList (LHsDecl GhcPs) -> [LHsDecl GhcPs] Source #

Function definitions are restructured here. Each is assumed to be recursive initially, and non recursive definitions are discovered by the dependency analyser.

placeHolderPunRhs :: DisambECP b => PV (LocatedA b) Source #

mkImport :: Located CCallConv -> Located Safety -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) Source #

parseCImport :: Located CCallConv -> Located Safety -> FastString -> String -> Located SourceText -> Maybe ForeignImport Source #

mkExport :: Located CCallConv -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) Source #

mkExtName :: RdrName -> CLabelString Source #

mkGadtDecl :: SrcSpan -> [LocatedN RdrName] -> LHsSigType GhcPs -> [AddEpAnn] -> P (LConDecl GhcPs) Source #

Construct a GADT-style data constructor from the constructor names and their type. Some interesting aspects of this function:

- This splits up the constructor type into its quantified type variables (if provided), context (if provided), argument types, and result type, and records whether this is a prefix or record GADT constructor. See Note [GADT abstract syntax] in GHC.Hs.Decls for more details.

mkConDeclH98 :: EpAnn [AddEpAnn] -> LocatedN RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs Source #

checkImportDecl :: Maybe EpaLocation -> Maybe EpaLocation -> P () Source #

checkExpBlockArguments :: LHsExpr GhcPs -> PV () Source #

Yield a parse error if we have a function applied directly to a do block etc. and BlockArguments is not enabled.

checkCmdBlockArguments :: LHsCmd GhcPs -> PV () Source #

checkPrecP Source #

Arguments

:: Located (SourceText, Int) | precedence
-> Located (OrdList (LocatedN RdrName)) | operators
-> P () |

Check if a fixity is valid. We support bypassing the usual bound checks for some special operators.

checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) Source #

Validate the context constraints and break up a context into a list of predicates.

        (Eq a, Ord b)        -->  [Eq a, Ord b]
        Eq a                 -->  [Eq a]
        (Eq a)               -->  [Eq a]
        (((Eq a)))           -->  [Eq a]

checkPattern :: LocatedA (PatBuilder GhcPs) -> P (LPat GhcPs) Source #

checkPattern_hints :: [Hint] -> PV (LocatedA (PatBuilder GhcPs)) -> P (LPat GhcPs) Source #

checkMonadComp :: PV (HsStmtContext GhcRn) Source #

Check for monad comprehensions

If the flag MonadComprehensions is set, return a `MonadComp` context, otherwise use the usual `ListComp` context

checkValDef :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> Maybe (AddEpAnn, LHsType GhcPs) -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) Source #

checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) Source #

type LRuleTyTmVar = Located RuleTyTmVar Source #

data RuleTyTmVar Source #

Essentially a wrapper for a `RuleBndr GhcPs`

Constructors

RuleTyTmVar (EpAnn [AddEpAnn]) (LocatedN RdrName) (Maybe (LHsType GhcPs)) |

mkRuleBndrs :: [LRuleTyTmVar] -> [LRuleBndr GhcPs] Source #

mkRuleTyVarBndrs :: [LRuleTyTmVar] -> [LHsTyVarBndr () GhcPs] Source #

checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P () Source #

checkRecordSyntax :: (MonadP m, Outputable a) => LocatedA a -> m (LocatedA a) Source #

checkEmptyGADTs :: Located ([AddEpAnn], [LConDecl GhcPs]) -> P (Located ([AddEpAnn], [LConDecl GhcPs])) Source #

Check if the gadt_constrlist is empty. Only raise parse error for `data T where` to avoid affecting existing error message, see #8258.

addFatalError :: MonadP m => PsError -> m a Source #

Add a fatal error. This will be the last error reported by the parser, and the parser will not produce any result, ending in a `PFailed` state.

hintBangPat :: SrcSpan -> Pat GhcPs -> PV () Source #

Hint about bang patterns, assuming `BangPatterns` is off.

mkBangTy :: EpAnn [AddEpAnn] -> SrcStrictness -> LHsType GhcPs -> HsType GhcPs Source #

data UnpackednessPragma Source #

Result of parsing `{-# UNPACK #-}` or `{-# NOUNPACK #-}`.

Constructors

UnpackednessPragma [AddEpAnn] SourceText SrcUnpackedness |

mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> HsArrow GhcPs Source #

data ImpExpSubSpec Source #

Constructors

ImpExpAbs |
ImpExpAll |
ImpExpList [LocatedA ImpExpQcSpec] |
ImpExpAllWith [LocatedA ImpExpQcSpec] |

data ImpExpQcSpec Source #

Constructors

ImpExpQcName (LocatedN RdrName) |
ImpExpQcType EpaLocation (LocatedN RdrName) |
ImpExpQcWildcard |

mkModuleImpExp :: [AddEpAnn] -> LocatedA ImpExpQcSpec -> ImpExpSubSpec -> P (IE GhcPs) Source #

mkTypeImpExp :: LocatedN RdrName -> P (LocatedN RdrName) Source #

mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) Source #

checkImportSpec :: LocatedL [LIE GhcPs] -> P (LocatedL [LIE GhcPs]) Source #

starSym :: Bool -> String Source #

warnStarIsType :: SrcSpan -> P () Source #

warnPrepositiveQualifiedModule :: SrcSpan -> P () Source #

failOpFewArgs :: MonadP m => LocatedN RdrName -> m a Source #

failOpNotEnabledImportQualifiedPost :: SrcSpan -> P () Source #

failOpImportQualifiedTwice :: SrcSpan -> P () Source #

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)] |

data PV a Source #

#### Instances

Instances details

Applicative PV Source # |
Instance details Defined in GHC.Parser.PostProcess Methods pure :: a -> PV a Source # (<*>) :: PV (a -> b) -> PV a -> PV b Source # liftA2 :: (a -> b -> c) -> PV a -> PV b -> PV c Source # (*>) :: PV a -> PV b -> PV b Source # (<*) :: PV a -> PV b -> PV a Source #
Functor PV Source # |
Instance details Defined in GHC.Parser.PostProcess Methods fmap :: (a -> b) -> PV a -> PV b Source # (<$) :: a -> PV b -> PV a Source #
Monad PV Source # |
Instance details Defined in GHC.Parser.PostProcess Methods (>>=) :: PV a -> (a -> PV b) -> PV b Source # (>>) :: PV a -> PV b -> PV b Source # return :: a -> PV a Source #
MonadP PV Source # |
Instance details Defined in GHC.Parser.PostProcess Methods addError :: PsError -> PV () Source # addWarning :: WarningFlag -> PsWarning -> PV () Source # addFatalError :: PsError -> PV a Source # getBit :: ExtBits -> PV Bool Source # allocateCommentsP :: RealSrcSpan -> PV EpAnnComments Source # allocatePriorCommentsP :: RealSrcSpan -> PV EpAnnComments Source # allocateFinalCommentsP :: RealSrcSpan -> PV EpAnnComments Source #

runPV :: PV a -> P a Source #

newtype ECP Source #

Constructors

ECP |
Fields unECP :: forall b. DisambECP b => PV (LocatedA b)

class DisambInfixOp b where Source #

Disambiguate infix operators. See Note [Ambiguous syntactic categories]

Methods

mkHsVarOpPV :: LocatedN RdrName -> PV (LocatedN b) Source #

mkHsConOpPV :: LocatedN RdrName -> PV (LocatedN b) Source #

mkHsInfixHolePV :: SrcSpan -> (EpAnnComments -> EpAnn EpAnnUnboundVar) -> PV (Located b) Source #

#### Instances

Instances details

DisambInfixOp RdrName Source # |
Instance details Defined in GHC.Parser.PostProcess Methods mkHsVarOpPV :: LocatedN RdrName -> PV (LocatedN RdrName) Source # mkHsConOpPV :: LocatedN RdrName -> PV (LocatedN RdrName) Source # mkHsInfixHolePV :: SrcSpan -> (EpAnnComments -> EpAnn EpAnnUnboundVar) -> PV (Located RdrName) Source #
DisambInfixOp (HsExpr GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess Methods mkHsVarOpPV :: LocatedN RdrName -> PV (LocatedN (HsExpr GhcPs)) Source # mkHsConOpPV :: LocatedN RdrName -> PV (LocatedN (HsExpr GhcPs)) Source # mkHsInfixHolePV :: SrcSpan -> (EpAnnComments -> EpAnn EpAnnUnboundVar) -> PV (Located (HsExpr GhcPs)) Source #

class (b ~ Body b GhcPs, AnnoBody b) => DisambECP b where Source #

Disambiguate constructs that may appear when we do not know ahead of time whether we are parsing an expression, a command, or a pattern. See Note [Ambiguous syntactic categories]

Associated Types

type Body b :: Type -> Type Source #

See Note [Body in DisambECP]

type InfixOp b Source #

Infix operator representation

type FunArg b Source #

Function argument representation

Methods

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

Return a command without ambiguity, or fail in a non-command context.

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

Return an expression without ambiguity, or fail in a non-expression context.

mkHsProjUpdatePV :: SrcSpan -> Located [Located (HsFieldLabel GhcPs)] -> LocatedA b -> Bool -> [AddEpAnn] -> PV (LHsRecProj GhcPs (LocatedA b)) Source #

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

Disambiguate "... -> ..." (lambda)

mkHsLetPV :: SrcSpan -> HsLocalBinds GhcPs -> LocatedA b -> AnnsLet -> PV (LocatedA b) Source #

Disambiguate "let ... in ..."

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

Bring superclass constraints on InfixOp into scope. See Note [UndecidableSuperClasses for associated types]

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

Disambiguate "f # x" (infix operator)

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

Disambiguate "case ... of ..."

mkHsLamCasePV :: SrcSpan -> LocatedL [LMatch GhcPs (LocatedA b)] -> [AddEpAnn] -> PV (LocatedA b) Source #

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

Bring superclass constraints on FunArg into scope. See Note [UndecidableSuperClasses for associated types]

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

Disambiguate "f x" (function application)

mkHsAppTypePV :: SrcSpanAnnA -> LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b) Source #

Disambiguate "f @t" (visible type application)

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

Disambiguate "if ... then ... else ..."

mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedL [LStmt GhcPs (LocatedA b)] -> AnnList -> PV (LocatedA b) Source #

Disambiguate "do { ... }" (do notation)

mkHsParPV :: SrcSpan -> LocatedA b -> AnnParen -> PV (LocatedA b) Source #

Disambiguate "( ... )" (parentheses)

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

Disambiguate a variable "f" or a data constructor MkF.

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

Disambiguate a monomorphic literal

mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located b) Source #

Disambiguate an overloaded literal

mkHsWildCardPV :: SrcSpan -> PV (Located b) Source #

Disambiguate a wildcard

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

Disambiguate "a :: t" (type annotation)

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

Disambiguate "[a,b,c]" (list syntax)

mkHsSplicePV :: Located (HsSplice GhcPs) -> PV (Located b) Source #

Disambiguate "$(...)" and "[quasi|...|]" (TH splices)

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

Disambiguate "f { a = b, ... }" syntax (record construction and record updates)

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

Disambiguate "-a" (negation)

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

Disambiguate "(# a)" (right operator section)

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

Disambiguate "(a -> b)" (view pattern)

mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) Source #

Disambiguate "a@b" (as-pattern)

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

Disambiguate "~a" (lazy pattern)

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

Disambiguate "!a" (bang pattern)

mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> [AddEpAnn] -> PV (LocatedA b) Source #

Disambiguate tuple sections and unboxed sums

rejectPragmaPV :: LocatedA b -> PV () Source #

Validate infixexp LHS to reject unwanted {-# SCC ... #-} pragmas

#### 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 [Located (HsFieldLabel 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 -> HsLocalBinds GhcPs -> LocatedA (PatBuilder GhcPs) -> AnnsLet -> 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 -> 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) -> SrcSpan -> 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 -> LocatedA (PatBuilder GhcPs) -> AnnParen -> PV (LocatedA (PatBuilder GhcPs)) Source # mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (PatBuilder GhcPs)) Source # mkHsLitPV :: Located (HsLit GhcPs) -> PV (Located (PatBuilder GhcPs)) Source # mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located (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 (HsSplice 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 -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> 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 #
DisambECP (HsCmd GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess Associated Types type Body (HsCmd GhcPs) :: Type -> Type Source # type InfixOp (HsCmd GhcPs) Source # type FunArg (HsCmd GhcPs) Source # Methods ecpFromCmd' :: LHsCmd GhcPs -> PV (LocatedA (HsCmd GhcPs)) Source # ecpFromExp' :: LHsExpr GhcPs -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsProjUpdatePV :: SrcSpan -> Located [Located (HsFieldLabel GhcPs)] -> LocatedA (HsCmd GhcPs) -> Bool -> [AddEpAnn] -> PV (LHsRecProj GhcPs (LocatedA (HsCmd GhcPs))) Source # mkHsLamPV :: SrcSpan -> (EpAnnComments -> MatchGroup GhcPs (LocatedA (HsCmd GhcPs))) -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsLetPV :: SrcSpan -> HsLocalBinds GhcPs -> LocatedA (HsCmd GhcPs) -> AnnsLet -> PV (LocatedA (HsCmd GhcPs)) Source # superInfixOp :: (DisambInfixOp (InfixOp (HsCmd GhcPs)) => PV (LocatedA (HsCmd GhcPs))) -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsOpAppPV :: SrcSpan -> LocatedA (HsCmd GhcPs) -> LocatedN (InfixOp (HsCmd GhcPs)) -> LocatedA (HsCmd GhcPs) -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsCasePV :: SrcSpan -> LHsExpr GhcPs -> LocatedL [LMatch GhcPs (LocatedA (HsCmd GhcPs))] -> EpAnnHsCase -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsLamCasePV :: SrcSpan -> LocatedL [LMatch GhcPs (LocatedA (HsCmd GhcPs))] -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # superFunArg :: (DisambECP (FunArg (HsCmd GhcPs)) => PV (LocatedA (HsCmd GhcPs))) -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsAppPV :: SrcSpanAnnA -> LocatedA (HsCmd GhcPs) -> LocatedA (FunArg (HsCmd GhcPs)) -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsAppTypePV :: SrcSpanAnnA -> LocatedA (HsCmd GhcPs) -> SrcSpan -> LHsType GhcPs -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsIfPV :: SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA (HsCmd GhcPs) -> Bool -> LocatedA (HsCmd GhcPs) -> AnnsIf -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedL [LStmt GhcPs (LocatedA (HsCmd GhcPs))] -> AnnList -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsParPV :: SrcSpan -> LocatedA (HsCmd GhcPs) -> AnnParen -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsLitPV :: Located (HsLit GhcPs) -> PV (Located (HsCmd GhcPs)) Source # mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located (HsCmd GhcPs)) Source # mkHsWildCardPV :: SrcSpan -> PV (Located (HsCmd GhcPs)) Source # mkHsTySigPV :: SrcSpanAnnA -> LocatedA (HsCmd GhcPs) -> LHsType GhcPs -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsExplicitListPV :: SrcSpan -> [LocatedA (HsCmd GhcPs)] -> AnnList -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsSplicePV :: Located (HsSplice GhcPs) -> PV (Located (HsCmd GhcPs)) Source # mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA (HsCmd GhcPs) -> ([Fbind (HsCmd GhcPs)], Maybe SrcSpan) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsNegAppPV :: SrcSpan -> LocatedA (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsSectionR_PV :: SrcSpan -> LocatedA (InfixOp (HsCmd GhcPs)) -> LocatedA (HsCmd GhcPs) -> PV (Located (HsCmd GhcPs)) Source # mkHsViewPatPV :: SrcSpan -> LHsExpr GhcPs -> LocatedA (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> LocatedA (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsLazyPatPV :: SrcSpan -> LocatedA (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkHsBangPatPV :: SrcSpan -> LocatedA (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (HsCmd GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsCmd GhcPs)) Source # rejectPragmaPV :: LocatedA (HsCmd GhcPs) -> PV () Source #
DisambECP (HsExpr GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess Associated Types type Body (HsExpr GhcPs) :: Type -> Type Source # type InfixOp (HsExpr GhcPs) Source # type FunArg (HsExpr GhcPs) Source # Methods ecpFromCmd' :: LHsCmd GhcPs -> PV (LocatedA (HsExpr GhcPs)) Source # ecpFromExp' :: LHsExpr GhcPs -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsProjUpdatePV :: SrcSpan -> Located [Located (HsFieldLabel GhcPs)] -> LocatedA (HsExpr GhcPs) -> Bool -> [AddEpAnn] -> PV (LHsRecProj GhcPs (LocatedA (HsExpr GhcPs))) Source # mkHsLamPV :: SrcSpan -> (EpAnnComments -> MatchGroup GhcPs (LocatedA (HsExpr GhcPs))) -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsLetPV :: SrcSpan -> HsLocalBinds GhcPs -> LocatedA (HsExpr GhcPs) -> AnnsLet -> PV (LocatedA (HsExpr GhcPs)) Source # superInfixOp :: (DisambInfixOp (InfixOp (HsExpr GhcPs)) => PV (LocatedA (HsExpr GhcPs))) -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsOpAppPV :: SrcSpan -> LocatedA (HsExpr GhcPs) -> LocatedN (InfixOp (HsExpr GhcPs)) -> LocatedA (HsExpr GhcPs) -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsCasePV :: SrcSpan -> LHsExpr GhcPs -> LocatedL [LMatch GhcPs (LocatedA (HsExpr GhcPs))] -> EpAnnHsCase -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsLamCasePV :: SrcSpan -> LocatedL [LMatch GhcPs (LocatedA (HsExpr GhcPs))] -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # superFunArg :: (DisambECP (FunArg (HsExpr GhcPs)) => PV (LocatedA (HsExpr GhcPs))) -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsAppPV :: SrcSpanAnnA -> LocatedA (HsExpr GhcPs) -> LocatedA (FunArg (HsExpr GhcPs)) -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsAppTypePV :: SrcSpanAnnA -> LocatedA (HsExpr GhcPs) -> SrcSpan -> LHsType GhcPs -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsIfPV :: SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA (HsExpr GhcPs) -> Bool -> LocatedA (HsExpr GhcPs) -> AnnsIf -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsDoPV :: SrcSpan -> Maybe ModuleName -> LocatedL [LStmt GhcPs (LocatedA (HsExpr GhcPs))] -> AnnList -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsParPV :: SrcSpan -> LocatedA (HsExpr GhcPs) -> AnnParen -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsLitPV :: Located (HsLit GhcPs) -> PV (Located (HsExpr GhcPs)) Source # mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located (HsExpr GhcPs)) Source # mkHsWildCardPV :: SrcSpan -> PV (Located (HsExpr GhcPs)) Source # mkHsTySigPV :: SrcSpanAnnA -> LocatedA (HsExpr GhcPs) -> LHsType GhcPs -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsExplicitListPV :: SrcSpan -> [LocatedA (HsExpr GhcPs)] -> AnnList -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsSplicePV :: Located (HsSplice GhcPs) -> PV (Located (HsExpr GhcPs)) Source # mkHsRecordPV :: Bool -> SrcSpan -> SrcSpan -> LocatedA (HsExpr GhcPs) -> ([Fbind (HsExpr GhcPs)], Maybe SrcSpan) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsNegAppPV :: SrcSpan -> LocatedA (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsSectionR_PV :: SrcSpan -> LocatedA (InfixOp (HsExpr GhcPs)) -> LocatedA (HsExpr GhcPs) -> PV (Located (HsExpr GhcPs)) Source # mkHsViewPatPV :: SrcSpan -> LHsExpr GhcPs -> LocatedA (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> LocatedA (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsLazyPatPV :: SrcSpan -> LocatedA (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkHsBangPatPV :: SrcSpan -> LocatedA (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # mkSumOrTuplePV :: SrcSpanAnnA -> Boxity -> SumOrTuple (HsExpr GhcPs) -> [AddEpAnn] -> PV (LocatedA (HsExpr GhcPs)) Source # rejectPragmaPV :: LocatedA (HsExpr GhcPs) -> PV () Source #

ecpFromExp :: LHsExpr GhcPs -> ECP Source #

ecpFromCmd :: LHsCmd GhcPs -> ECP Source #

data PatBuilder p Source #

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

#### 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 [Located (HsFieldLabel 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 -> HsLocalBinds GhcPs -> LocatedA (PatBuilder GhcPs) -> AnnsLet -> 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 -> 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) -> SrcSpan -> 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 -> LocatedA (PatBuilder GhcPs) -> AnnParen -> PV (LocatedA (PatBuilder GhcPs)) Source # mkHsVarPV :: LocatedN RdrName -> PV (LocatedA (PatBuilder GhcPs)) Source # mkHsLitPV :: Located (HsLit GhcPs) -> PV (Located (PatBuilder GhcPs)) Source # mkHsOverLitPV :: Located (HsOverLit GhcPs) -> PV (Located (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 (HsSplice 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 -> LocatedA (PatBuilder GhcPs) -> [AddEpAnn] -> 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))) = SrcSpan
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

class DisambTD b where Source #

Disambiguate constructs that may appear when we do not know ahead of time whether we are parsing a type or a newtype/data constructor.

See Note [Ambiguous syntactic categories] for the general idea.

See Note [Parsing data constructors is hard] for the specific issue this particular class is solving.

Methods

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

Process the head of a type-level function/constructor application, i.e. the `H` in `H a b c`.

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

Disambiguate `f x` (function application or prefix data constructor).

mkHsAppKindTyPV :: LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b) Source #

Disambiguate `f @t` (visible kind application)

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

Disambiguate `f # x` (infix operator)

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

Disambiguate `{-# UNPACK #-} t` (unpack/nounpack pragma)

#### 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 :: LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA DataConBuilder) Source # mkUnpackednessPV :: Located UnpackednessPragma -> LocatedA DataConBuilder -> PV (LocatedA DataConBuilder) Source #
DisambTD (HsType GhcPs) Source # |
Instance details Defined in GHC.Parser.PostProcess Methods mkHsAppTyHeadPV :: LHsType GhcPs -> PV (LocatedA (HsType GhcPs)) Source # mkHsAppTyPV :: LocatedA (HsType GhcPs) -> LHsType GhcPs -> PV (LocatedA (HsType GhcPs)) Source # mkHsAppKindTyPV :: LocatedA (HsType GhcPs) -> SrcSpan -> LHsType GhcPs -> PV (LocatedA (HsType GhcPs)) Source # mkHsOpTyPV :: LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA (HsType GhcPs)) Source # mkUnpackednessPV :: Located UnpackednessPragma -> LocatedA (HsType GhcPs) -> PV (LocatedA (HsType GhcPs)) Source #

addUnpackednessP :: MonadP m => Located UnpackednessPragma -> LHsType GhcPs -> m (LHsType GhcPs) Source #

Annotate a type with either an `{-# UNPACK #-}` or a `{-# NOUNPACK #-}` pragma.

dataConBuilderCon :: DataConBuilder -> LocatedN RdrName Source #

dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs Source #