Parenthesize an expression without token information
Moduleghc-9.14.1GHC2021
GHC.Hs.Expr
Abstract Haskell syntax for expressions.
- 43 types
- 107 values
- Packageghc-9.14.1
- Exports158
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceExpr.hs
module Language.Haskell.Syntax.Expr
hsExprNeedsParens p e returns True if the expression e needs
parentheses under precedence p.
Is there only one RHS in this list of matches?
mkExpandedExpr Build an expression using the extension constructor XExpr, and the two components of the expansion: original expression and expanded expressions.
mkExpandedExprTc Build a XXExprGhcRn out of an extension constructor, and the two components of the expansion: original and expanded typechecked expressions.
mkExpandedPatRn mkExpandedStmt Build an expression using the extension constructor XExpr, and the two components of the expansion: original do stmt and expanded expression
mkExpandedStmtAt :: SrcSpanAnnALocation for the expansion expression
-> ExprLStmt GhcRnsource statement
-> HsExpr GhcRnexpanded expression
-> LHsExpr GhcRnsuitably wrapped located XXExprGhcRn
Build an expression using the extension constructor XExpr, and the two components of the expansion: original do stmt and expanded expression an associate with a provided location
mkExpandedStmtPopAt :: SrcSpanAnnALocation for the expansion statement
-> ExprLStmt GhcRnsource statement
-> HsExpr GhcRnexpanded expression
-> LHsExpr GhcRnsuitably wrapped XXExprGhcRn
Wrap the expanded version of the expression with a pop.
mkExpandedStmtTc Build a XXExprGhcRn out of an extension constructor. The two components of the expansion are: original statement and expanded typechecked expression.
Wrap a located expression with a PopErrCtxt
Wrap a located expression with a PopSrcExpr with an appropriate location
Make a 'SyntaxExpr GhcRn' from an expression Used only in getMonadFailOp. See Note [Monad fail : Rebindable syntax, overloaded strings] in GHC.Rename.Expr
This is used for rebindable-syntax pieces that are too polymorphic for tcSyntaxOp (trS_fmap and the mzip in ParStmt)
parenthesizeHsExpr p e checks if hsExprNeedsParens p e is true,
and if so, surrounds e with an HsPar. Otherwise, it simply returns e.
The RdrName for an unnamed hole ("_").
Constructors
Instances2Data, NoAnn
Data AnnArithSeqDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn AnnArithSeqDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
AnnExplicitSumaesOpen :: EpaLocationaesBarsBefore :: [EpToken"|"
]aesBarsAfter :: [EpToken"|"
]aesClose :: EpaLocation
Instances2Data, NoAnn
Data AnnExplicitSumDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn AnnExplicitSumDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
Instances2Data, NoAnn
Data AnnFieldLabelDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn AnnFieldLabelDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
AnnFunRhsafr_strict :: EpToken"!"
afr_opens :: [EpToken"("
]afr_closes :: [EpToken")"
]
Constructors
Instances2Data, NoAnn
Data AnnProjectionDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn AnnProjectionDefined in ghc-9.14.1 · GHC.Hs.Expr
Instances2Data, NoAnn
Data AnnTransStmtDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn AnnTransStmtDefined in ghc-9.14.1 · GHC.Hs.Expr
Applicative Argument
Constructors
ApplicativeArgOnexarg_app_arg_one :: XApplicativeArgOne idLThe fail operator, after renaming
The fail operator is needed if this is a BindStmt where the pattern can fail. E.g.: (Just a) <- stmt The fail operator will be invoked if the pattern match fails. It is also used for guards in MonadComprehensions. The fail operator is Nothing if the pattern match can't fail
app_arg_pattern :: LPat idLarg_expr :: LHsExpr idLis_body_stmt :: Bool
ApplicativeArgManyxarg_app_arg_many :: XApplicativeArgMany idLapp_stmts :: [ExprLStmt idL]final_expr :: HsExpr idLbv_pattern :: LPat idLstmt_context :: HsDoFlavourcontext of the do expression, used in pprArg
XApplicativeArg !(XXApplicativeArg idL)
Instances6Data, Outputable, CollectFldBinders, ToHie
Data (ApplicativeArg GhcPs)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeArg GhcRn)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeArg GhcTc)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputableBndrId idL => Outputable (ApplicativeArg (GhcPass idL))Defined in ghc-9.14.1 · GHC.Hs.ExprCollectFldBinders (ApplicativeArg GhcTc)Defined in ghc-9.14.1 · GHC.HsToCore.TicksHiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p)))Defined in ghc-9.14.1 · GHC.Iface.Ext.Ast
ApplicativeStmt represents an applicative expression built with <$> and <*>. It is generated by the renamer, and is desugared into the appropriate applicative expression by the desugarer, but it is intended to be invisible in error messages.
For full details, see Note [ApplicativeDo] in GHC.Rename.Expr
Constructors
ApplicativeStmt (XApplicativeStmt idL idR) [(SyntaxExpr idR, ApplicativeArg idL)] (Maybe (SyntaxExpr idR))
Instances9Data, …
Data (ApplicativeStmt GhcPs GhcPs)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcPs GhcRn)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcPs GhcTc)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcRn GhcPs)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcRn GhcRn)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcRn GhcTc)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcTc GhcPs)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcTc GhcRn)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (ApplicativeStmt GhcTc GhcTc)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Constructors
BracketNoE noEBracketHasE hasE
Instances2Data, NoAnn
(Data noE, Data hasE) => Data (BracketAnn noE hasE)Defined in ghc-9.14.1 · GHC.Hs.Expr(NoAnn n, NoAnn h) => NoAnn (BracketAnn n h)Defined in ghc-9.14.1 · GHC.Hs.Expr
Command Syntax Table (for Arrow syntax)
Constructors
Instances1Data
Data DelayedSpliceDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
EpAnnHsCasehsCaseAnnCase :: EpToken"case"
hsCaseAnnOf :: EpToken"of"
Instances2Data, NoAnn
Data EpAnnHsCaseDefined in ghc-9.14.1 · GHC.Hs.ExprNoAnn EpAnnHsCaseDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
EpAnnLamepl_lambda :: EpToken"\\"
Location of
\keywordepl_case :: Maybe EpaLocationLocation of
caseorcaseskeyword, depending on related HsLamVariant.
Constructors
Instances1Data
Data HsBracketTcDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Information about an implicit lift, discovered by the renamer See Note [Lifecycle of an untyped splice, and PendingRnSplice]
Instances1Data
Data HsImplicitLiftSpliceDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Information about a quasi-quoter, discovered by the renamer See Note [Lifecycle of an untyped splice, and PendingRnSplice]
Constructors
Instances1Data
Data HsQuasiQuoteExtDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Information about the parent of a record update:
the parent type constructor or pattern synonym,
the relevant con-likes,
the field labels.
Instances6Data, HsRecUpdParent
Data (HsRecUpdParent GhcPs)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (HsRecUpdParent GhcRn)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphanData (HsRecUpdParent GhcTc)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphandata HsRecUpdParent GhcPsDefined in ghc-9.14.1 · GHC.Hs.Exprdata HsRecUpdParent GhcRnDefined in ghc-9.14.1 · GHC.Hs.Exprdata HsRecUpdParent GhcTcTcRecUpdParenttcRecUpdParent :: RecSelParenttcRecUpdLabels :: NonEmpty FieldGlobalRdrElttcRecUpdCons :: UniqSet ConLike
The different source constructs that we use to instantiate the "original" field in an `XXExprGhcRn original expansion`
Instances2Data, Outputable
Data HsThingRnDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable HsThingRnDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
Instances1Data
Data HsTypedSpliceResultDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Constructors
HsUntypedSpliceToputsplice_result_finalizers :: ThModFinalizersTH finalizers produced by the splice.
utsplice_result :: thingThe result of splicing; See Note [Lifecycle of a splice]
HsUntypedSpliceNested SplicePointName
Instances1Data
Data a => Data (HsUntypedSpliceResult a)Defined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Information about a user-written splice, discovered by the renamer See Note [Lifecycle of an untyped splice, and PendingRnSplice]
Constructors
Instances1Data
Data HsUserSpliceExtDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Constructors
Instances1Data
Data MatchGroupTcDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
Instances3Data, Outputable, ToHie
Data PendingRnSpliceDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable PendingRnSpliceDefined in ghc-9.14.1 · GHC.Hs.ExprToHie PendingRnSpliceDefined in ghc-9.14.1 · GHC.Iface.Ext.Ast
Pending Type-checker Splice See Note [Lifecycle of an untyped splice, and PendingRnSplice]
Constructors
Instances3Data, Outputable, ToHie
Data PendingTcSpliceDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable PendingTcSpliceDefined in ghc-9.14.1 · GHC.Hs.ExprToHie PendingTcSpliceDefined in ghc-9.14.1 · GHC.Iface.Ext.Ast
Post-Type checking Expression
PostTcExpr is an evidence expression attached to the syntax tree by the type checker (c.f. postTcType).
Post-Type checking Table
We use a PostTcTable where there are a bunch of pieces of evidence, more than is convenient to keep individually.
Constructors
The function to use in rebindable syntax. See Note [NoSyntaxExpr].
Constructors
Instances3Data, Outputable, ToHie
Data SyntaxExprRnDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable SyntaxExprRnDefined in ghc-9.14.1 · GHC.Hs.ExprToHie (LocatedA SyntaxExprRn)Defined in ghc-9.14.1 · GHC.Iface.Ext.Ast
An expression with wrappers, used for rebindable syntax
This should desugar to
syn_res_wrap $ syn_expr (syn_arg_wraps[0] arg0)
(syn_arg_wraps[1] arg1) ...where the actual arguments come from elsewhere in the AST.
Constructors
Instances3Data, Outputable, ToHie
Data SyntaxExprTcDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable SyntaxExprTcDefined in ghc-9.14.1 · GHC.Hs.ExprToHie (LocatedA SyntaxExprTc)Defined in ghc-9.14.1 · GHC.Iface.Ext.Ast
Finalizers produced by a splice with addModFinalizer
See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice. For how this is used.
Constructors
ThModFinalizers [ForeignRef (Q ())]
Instances1Data
Data ThModFinalizersDefined in ghc-9.14.1 · GHC.Hs.Expr
Instances1Data
Data UntypedSpliceFlavourDefined in ghc-9.14.1 · GHC.Hs.Expr
Instances1XApplicativeArgMany
type XApplicativeArgMany (GhcPass _1) = NoExtFieldDefined in ghc-9.14.1 · GHC.Hs.Expr
Instances3XApplicativeArgOne
type XApplicativeArgOne GhcPs = NoExtFieldDefined in ghc-9.14.1 · GHC.Hs.Exprtype XApplicativeArgOne GhcRn = FailOperator GhcRnDefined in ghc-9.14.1 · GHC.Hs.Exprtype XApplicativeArgOne GhcTc = FailOperator GhcTcDefined in ghc-9.14.1 · GHC.Hs.Expr
Instances3XApplicativeStmt
type XApplicativeStmt (GhcPass _1) GhcPs = NoExtFieldDefined in ghc-9.14.1 · GHC.Hs.Exprtype XApplicativeStmt (GhcPass _1) GhcRn = NoExtFieldDefined in ghc-9.14.1 · GHC.Hs.Exprtype XApplicativeStmt (GhcPass _1) GhcTc = TypeDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
Instances1Data
Data XBindStmtRnDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Constructors
Instances1Data
Data XBindStmtTcDefined in ghc-9.14.1 · GHC.Hs.Instances · orphan
Instances1XXApplicativeArg
type XXApplicativeArg (GhcPass _1) = DataConCantHappenDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
ExpandedThingRnPopErrCtxt !(LHsExpr GhcRn)HsRecSelRn (FieldOcc GhcRn)Variable pointing to record selector See Note [Non-overloaded record field selectors] and Note [Record selectors in the AST]
Instances2Data, Outputable
Data XXExprGhcRnDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable XXExprGhcRnDefined in ghc-9.14.1 · GHC.Hs.Expr
Constructors
WrapExpr HsWrapper (HsExpr GhcTc)ExpandedThingTcConLikeTc ConLike [TcTyVar] [Scaled TcType]HsTick CoreTickish (LHsExpr GhcTc)HsBinTick Int Int (LHsExpr GhcTc)HsRecSelTc (FieldOcc GhcTc)Variable pointing to record selector See Note [Non-overloaded record field selectors] and Note [Record selectors in the AST]
Instances2Data, Outputable
Data XXExprGhcTcDefined in ghc-9.14.1 · GHC.Hs.Instances · orphanOutputable XXExprGhcTcDefined in ghc-9.14.1 · GHC.Hs.Expr
Orphan instances
18 instancesOutputable HsArrowMatchContextOutputable HsLamVariantOutputableBndrId p => Outputable (ArithSeqInfo (GhcPass p))OutputableBndrId p => Outputable (HsCmd (GhcPass p))OutputableBndrId p => Outputable (HsCmdTop (GhcPass p))OutputableBndrId p => Outputable (HsExpr (GhcPass p))OutputableBndrId p => Outputable (HsQuote (GhcPass p))Outputable (HsPragE (GhcPass p))Outputable fn => Outputable (HsMatchContext fn)Outputable fn => Outputable (HsStmtContext fn)UnXRec p => Outputable (DotFieldOcc p)(UnXRec p, Outputable (XRec p FieldLabelString)) => Outputable (FieldLabelStrings p)(UnXRec p, Outputable (XRec p FieldLabelString)) => OutputableBndr (Located (FieldLabelStrings p))(UnXRec p, Outputable (XRec p FieldLabelString)) => OutputableBndr (FieldLabelStrings p)HasAnnotation (Anno a) => WrapXRec (GhcPass p) a(OutputableBndrId pr, Outputable body) => Outputable (Match (GhcPass pr) body)(Outputable (StmtLR (GhcPass idL) (GhcPass idL) (LHsExpr (GhcPass idL))), Outputable (XXParStmtBlock (GhcPass idL) (GhcPass idR))) => Outputable (ParStmtBlock (GhcPass idL) (GhcPass idR))(OutputableBndrId pl, OutputableBndrId pr, Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA, Outputable body) => Outputable (StmtLR (GhcPass pl) (GhcPass pr) body)