- ; (simple_wanted, tc_binds)
- <- simplifyAsMuchAsPossible SimplInfer zonked_wanted
-
+ -- Make a guess at the quantified type variables
+ -- Then split the constraints on the baisis of those tyvars
+ -- to avoid unnecessarily simplifying a class constraint
+ -- See Note [Avoid unecessary constraint simplification]
+ ; gbl_tvs <- tcGetGlobalTyVars
+ ; zonked_tau_tvs <- zonkTcTyVarsAndFV tau_tvs
+ ; let proto_qtvs = growWanteds gbl_tvs zonked_wanted $
+ zonked_tau_tvs `minusVarSet` gbl_tvs
+ (perhaps_bound, surely_free)
+ = partitionBag (quantifyMeWC proto_qtvs) zonked_wanted
+ ; emitConstraints surely_free
+ ; traceTc "sinf" (ppr proto_qtvs $$ ppr perhaps_bound $$ ppr surely_free)
+
+ -- Now simplify the possibly-bound constraints
+ ; (simplified_perhaps_bound, tc_binds)
+ <- simplifyAsMuchAsPossible SimplInfer perhaps_bound
+
+ -- Sigh: must re-zonk because because simplifyAsMuchAsPossible
+ -- may have done some unification