diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-01-15 15:10:08 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-01-15 15:10:38 -0500 |
commit | 287ab5231851e70a8ac7a8897e0a42d01f63eba6 (patch) | |
tree | 1345b1484f2fc130eff30afa9054c132ecfecc97 | |
parent | 30be3bf13a6e72247ff561df1f291370dad79ef9 (diff) | |
download | haskell-wip/T17659.tar.gz |
Add missing Note [Improvement from Ground Wanteds]wip/T17659
Closes #17659.
-rw-r--r-- | compiler/typecheck/TcCanonical.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs index f8bd367252..a53cdac72e 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 |