- get_m_arg ty
- = newTyVarTy mkTypeKind `thenNF_Tc` \ arg_ty ->
- unifyTauTy (mkAppTy m arg_ty) ty `thenTc_`
- returnTc arg_ty
-
- go [stmt@(ExprStmt exp src_loc)]
- = tcAddSrcLoc src_loc $
- tcSetErrCtxt (stmtCtxt stmt) $
- tcExpr exp `thenTc` \ (exp', exp_lie, exp_ty) ->
- returnTc ([ExprStmt exp' src_loc], exp_lie, exp_ty)
-
- go (stmt@(ExprStmt exp src_loc) : stmts)
- = tcAddSrcLoc src_loc (
- tcSetErrCtxt (stmtCtxt stmt) (
- tcExpr exp `thenTc` \ (exp', exp_lie, exp_ty) ->
- get_m_arg exp_ty `thenTc` \ a ->
- returnTc (a, exp', exp_lie)
- )) `thenTc` \ (a, exp', exp_lie) ->
- go stmts `thenTc` \ (stmts', stmts_lie, stmts_ty) ->
- get_m_arg stmts_ty `thenTc` \ b ->
- returnTc (ExprStmtOut exp' src_loc a b : stmts',
- exp_lie `plusLIE` stmts_lie `plusLIE` m_lie,
- stmts_ty)
-
- go (stmt@(BindStmt pat exp src_loc) : stmts)
- = newMonoIds (collectPatBinders pat) mkBoxedTypeKind $ \ _ ->
- tcAddSrcLoc src_loc (
- tcSetErrCtxt (stmtCtxt stmt) (
- tcPat pat `thenTc` \ (pat', pat_lie, pat_ty) ->
- tcExpr exp `thenTc` \ (exp', exp_lie, exp_ty) ->
- -- See comments with tcListComp on GeneratorQual
-
- get_m_arg exp_ty `thenTc` \ a ->
- unifyTauTy a pat_ty `thenTc_`
- returnTc (a, pat', exp', pat_lie `plusLIE` exp_lie)
- )) `thenTc` \ (a, pat', exp', stmt_lie) ->
- go stmts `thenTc` \ (stmts', stmts_lie, stmts_ty) ->
- get_m_arg stmts_ty `thenTc` \ b ->
- returnTc (BindStmtOut pat' exp' src_loc a b : stmts',
- stmt_lie `plusLIE` stmts_lie `plusLIE` m_lie `plusLIE`
- (if failureFreePat pat' then emptyLIE else mz_lie),
- stmts_ty)
-
- go (LetStmt binds : stmts)
- = tcBindsAndThen -- No error context, but a binding group is
- combine -- rather a large thing for an error context anyway
- binds
- (go stmts)
- where
- combine binds' stmts' = LetStmt binds' : stmts'