summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Solver.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-06-02 10:14:55 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-28 16:57:28 -0400
commit755cb2b0c161d306497b7581b984f62ca23bca15 (patch)
tree8fa9ab6364a9fd608b64a51a2f211353f0003314 /compiler/GHC/Tc/Solver.hs
parentd4c43df13d428b1acee2149618f8503580303486 (diff)
downloadhaskell-755cb2b0c161d306497b7581b984f62ca23bca15.tar.gz
Try to simplify zoo of functions in `Tc.Utils.Monad`
This commit tries to untangle the zoo of diagnostic-related functions in `Tc.Utils.Monad` so that we can have the interfaces mentions only `TcRnMessage`s while we push the creation of these messages upstream. It also ports TcRnMessage diagnostics to use the new API, in particular this commit switch to use TcRnMessage in the external interfaces of the diagnostic functions, and port the old SDoc to be wrapped into TcRnUnknownMessage.
Diffstat (limited to 'compiler/GHC/Tc/Solver.hs')
-rw-r--r--compiler/GHC/Tc/Solver.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/Solver.hs b/compiler/GHC/Tc/Solver.hs
index b37cc33451..3840d833b4 100644
--- a/compiler/GHC/Tc/Solver.hs
+++ b/compiler/GHC/Tc/Solver.hs
@@ -39,6 +39,7 @@ import GHC.Utils.Outputable
import GHC.Builtin.Utils
import GHC.Builtin.Names
import GHC.Tc.Errors
+import GHC.Tc.Errors.Types
import GHC.Tc.Types.Evidence
import GHC.Tc.Solver.Interact
import GHC.Tc.Solver.Canonical ( makeSuperClasses, solveCallStack )
@@ -1343,10 +1344,10 @@ decideMonoTyVars infer_mode name_taus psigs candidates
mono_tvs = mono_tvs2 `unionVarSet` constrained_tvs
-- Warn about the monomorphism restriction
- ; when (case infer_mode of { ApplyMR -> True; _ -> False}) $
- diagnosticTc (WarningWithFlag Opt_WarnMonomorphism)
- (constrained_tvs `intersectsVarSet` tyCoVarsOfTypes taus)
- mr_msg
+ ; when (case infer_mode of { ApplyMR -> True; _ -> False}) $ do
+ let dia = TcRnUnknownMessage $
+ mkPlainDiagnostic (WarningWithFlag Opt_WarnMonomorphism) noHints mr_msg
+ diagnosticTc (constrained_tvs `intersectsVarSet` tyCoVarsOfTypes taus) dia
; traceTc "decideMonoTyVars" $ vcat
[ text "infer_mode =" <+> ppr infer_mode
@@ -1794,7 +1795,8 @@ maybe_simplify_again n limit unif_happened wc@(WC { wc_simple = simples })
-- Typically if we blow the limit we are going to report some other error
-- (an unsolved constraint), and we don't want that error to suppress
-- the iteration limit warning!
- addErrTcS (hang (text "solveWanteds: too many iterations"
+ addErrTcS $ TcRnUnknownMessage $ mkPlainError noHints $
+ (hang (text "solveWanteds: too many iterations"
<+> parens (text "limit =" <+> ppr limit))
2 (vcat [ text "Unsolved:" <+> ppr wc
, text "Set limit with -fconstraint-solver-iterations=n; n=0 for no limit"