- zonkStmts env1 segStmts `thenM` \ new_segStmts ->
- zonkExprs env1 rets `thenM` \ new_rets ->
- zonkStmts env1 stmts `thenM` \ new_stmts ->
- returnM (RecStmt new_vs new_segStmts new_rets : new_stmts)
-
-zonkStmts env (ResultStmt expr locn : stmts)
- = zonkExpr env expr `thenM` \ new_expr ->
- zonkStmts env stmts `thenM` \ new_stmts ->
- returnM (ResultStmt new_expr locn : new_stmts)
+ zonk_stmts env1 segStmts `thenM` \ (env2, new_segStmts) ->
+ -- Zonk the ret-expressions in an envt that
+ -- has the polymorphic bindings in the envt
+ zonkExprs env2 rets `thenM` \ new_rets ->
+ zonk_stmts env1 stmts `thenM` \ (env3, new_stmts) ->
+ returnM (env3, RecStmt new_vs new_segStmts new_rets : new_stmts)
+
+zonk_stmts env (ResultStmt expr locn : stmts)
+ = ASSERT( null stmts )
+ zonkExpr env expr `thenM` \ new_expr ->
+ returnM (env, [ResultStmt new_expr locn])