+ loop ((bndrs,stmts) : pairs)
+ = tcStmtsAndThen
+ combine_par ListComp (mkListTy, not_required) stmts
+ (tcLookupLocalIds bndrs `thenNF_Tc` \ bndrs' ->
+ loop pairs `thenTc` \ ((pairs', thing), lie) ->
+ returnTc (([], (bndrs', pairs', thing)), lie)) `thenTc` \ ((stmts', (bndrs', pairs', thing)), lie) ->
+
+ returnTc ( ((bndrs',stmts') : pairs', thing), lie)
+
+ combine_par stmt (stmts, thing) = (stmt:stmts, thing)
+ not_required = panic "tcStmtsAndThen: elt_ty"
+
+ -- The simple-statment case
+tcStmtsAndThen combine do_or_lc m_ty (stmt:stmts) do_next
+ = tcSetErrCtxt (stmtCtxt do_or_lc stmt) (
+ tcSimpleStmt do_or_lc m_ty stmt (null stmts)
+ ) `thenTc` \ (stmt', stmt_lie) ->
+
+ tcStmtsAndThen combine do_or_lc m_ty stmts do_next `thenTc` \ (thing, stmts_lie) ->
+
+ returnTc (combine stmt' thing,
+ stmt_lie `plusLIE` stmts_lie)
+
+
+------------------------------
+ -- ReturnStmt
+tcSimpleStmt do_or_lc (_,elt_ty) (ReturnStmt exp) is_last_stmt
+ = ASSERT( is_last_stmt )
+ tcExpr exp elt_ty `thenTc` \ (exp', exp_lie) ->
+ returnTc (ReturnStmt exp', exp_lie)
+
+ -- ExprStmt
+tcSimpleStmt do_or_lc (m, elt_ty) (ExprStmt exp src_loc) is_last_stmt
+ = tcAddSrcLoc src_loc $
+ (if is_last_stmt then -- do { ... ; wuggle } wuggle : m elt_ty
+ returnNF_Tc elt_ty
+ else -- do { ... ; wuggle ; .... } wuggle : m any_ty
+ ASSERT( isDoStmt do_or_lc )
+ newTyVarTy openTypeKind
+ ) `thenNF_Tc` \ arg_ty ->
+ tcExpr exp (m arg_ty) `thenTc` \ (exp', exp_lie) ->
+ returnTc (ExprStmt exp' src_loc, exp_lie)
+
+ -- GuardStmt
+tcSimpleStmt do_or_lc m_ty (GuardStmt exp src_loc) is_last_stmt
+ = ASSERT( not (isDoStmt do_or_lc) )
+ tcAddSrcLoc src_loc $
+ tcExpr exp boolTy `thenTc` \ (exp', exp_lie) ->
+ returnTc (GuardStmt exp' src_loc, exp_lie)