summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-15 20:10:08 (GMT)
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-20 20:35:57 (GMT)
commit7e0bb82b5e267596c18e1086afd6007a00d2c072 (patch)
treee187f048b8979f93b7258843f3a277d46cb3fc66
parent14bced999dc8c826a9a10dfd922dadf2d681ffe3 (diff)
downloadghc-7e0bb82b5e267596c18e1086afd6007a00d2c072.zip
ghc-7e0bb82b5e267596c18e1086afd6007a00d2c072.tar.gz
ghc-7e0bb82b5e267596c18e1086afd6007a00d2c072.tar.bz2
Add missing Note [Improvement from Ground Wanteds]
Closes #17659.
-rw-r--r--compiler/typecheck/TcCanonical.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs
index f8bd367..a53cdac 100644
--- a/compiler/typecheck/TcCanonical.hs
+++ b/compiler/typecheck/TcCanonical.hs
@@ -543,6 +543,19 @@ mk_strict_superclasses rec_clss ev tvs theta cls tys
= do { sc_ev <- newDerivedNC loc sc_pred
; mk_superclasses rec_clss sc_ev [] [] sc_pred }
+{- Note [Improvement from Ground Wanteds]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Suppose class C b a => D a b
+and consider
+ [W] D Int Bool
+Is there any point in emitting [D] C Bool Int? No! The only point of
+emitting superclass constraints for W/D constraints is to get
+improvement, extra unifications that result from functional
+dependencies. See Note [Why adding superclasses can help] above.
+
+But no variables means no improvement; case closed.
+-}
+
mk_superclasses :: NameSet -> CtEvidence
-> [TyVar] -> ThetaType -> PredType -> TcS [Ct]
-- Return this constraint, plus its superclasses, if any