-data Stmt id
- = BindStmt (LPat id)
- (LHsExpr id)
- (SyntaxExpr id) -- The (>>=) operator
- (SyntaxExpr id) -- The fail operator
- -- The fail operator is noSyntaxExpr
- -- if the pattern match can't fail
-
- | ExprStmt (LHsExpr id)
- (SyntaxExpr id) -- The (>>) operator
- PostTcType -- Element type of the RHS (used for arrows)
-
- | LetStmt (HsLocalBinds id)
-
- -- ParStmts only occur in a list comprehension
- | ParStmt [([LStmt id], [id])] -- After renaming, the ids are the binders
- -- bound by the stmts and used subsequently
-
- -- Recursive statement (see Note [RecStmt] below)
- | RecStmt [LStmt id]
- --- The next two fields are only valid after renaming
- [id] -- The ids are a subset of the variables bound by the stmts
- -- that are used in stmts that follow the RecStmt
-
- [id] -- Ditto, but these variables are the "recursive" ones, that
- -- are used before they are bound in the stmts of the RecStmt
- -- From a type-checking point of view, these ones have to be monomorphic
-
- --- These fields are only valid after typechecking
- [PostTcExpr] -- These expressions correspond
- -- 1-to-1 with the "recursive" [id], and are the expresions that
- -- should be returned by the recursion. They may not quite be the
- -- Ids themselves, because the Id may be *polymorphic*, but
- -- the returned thing has to be *monomorphic*.
- (DictBinds id) -- Method bindings of Ids bound by the RecStmt,
- -- and used afterwards
+data StmtLR idL idR
+ = BindStmt (LPat idL)
+ (LHsExpr idR)
+ (SyntaxExpr idR) -- The (>>=) operator
+ (SyntaxExpr idR) -- The fail operator
+ -- The fail operator is noSyntaxExpr
+ -- if the pattern match can't fail
+
+ | ExprStmt (LHsExpr idR)
+ (SyntaxExpr idR) -- The (>>) operator
+ PostTcType -- Element type of the RHS (used for arrows)
+
+ | LetStmt (HsLocalBindsLR idL idR)
+
+ -- ParStmts only occur in a list comprehension
+ | ParStmt [([LStmt idL], [idR])]
+ -- After renaming, the ids are the binders bound by the stmts and used
+ -- after them
+
+ | TransformStmt ([LStmt idL], [idR]) (LHsExpr idR) (Maybe (LHsExpr idR))
+ -- After renaming, the IDs are the binders occurring within this
+ -- transform statement that are used after it
+ -- "qs, then f by e" ==> TransformStmt (qs, binders) f (Just e)
+ -- "qs, then f" ==> TransformStmt (qs, binders) f Nothing
+
+ | GroupStmt ([LStmt idL], [(idR, idR)]) (GroupByClause idR)
+ -- After renaming, the IDs are the binders occurring within this
+ -- transform statement that are used after it which are paired with
+ -- the names which they group over in statements
+
+ -- Recursive statement (see Note [RecStmt] below)
+ | RecStmt
+ { recS_stmts :: [LStmtLR idL idR]
+
+ -- The next two fields are only valid after renaming
+ , recS_later_ids :: [idR] -- The ids are a subset of the variables bound by the
+ -- stmts that are used in stmts that follow the RecStmt
+
+ , recS_rec_ids :: [idR] -- Ditto, but these variables are the "recursive" ones,
+ -- that are used before they are bound in the stmts of
+ -- the RecStmt.
+ -- An Id can be in both groups
+ -- Both sets of Ids are (now) treated monomorphically
+ -- See Note [How RecStmt works] for why they are separate
+
+ -- Rebindable syntax
+ , recS_bind_fn :: SyntaxExpr idR -- The bind function
+ , recS_ret_fn :: SyntaxExpr idR -- The return function
+ , recS_mfix_fn :: SyntaxExpr idR -- The mfix function
+
+ -- These fields are only valid after typechecking
+ , recS_rec_rets :: [PostTcExpr] -- These expressions correspond 1-to-1 with
+ -- recS_rec_ids, and are the
+ -- expressions that should be returned by
+ -- the recursion.
+ -- They may not quite be the Ids themselves,
+ -- because the Id may be *polymorphic*, but
+ -- the returned thing has to be *monomorphic*,
+ -- so they may be type applications
+
+ , recS_dicts :: DictBinds idR -- Method bindings of Ids bound by the
+ -- RecStmt, and used afterwards
+ }