[Git][ghc/ghc][wip/T26004] Wibbles

Simon Peyton Jones pushed to branch wip/T26004 at Glasgow Haskell Compiler / GHC Commits: ca6cd646 by Simon Peyton Jones at 2025-04-30T08:44:33+01:00 Wibbles - - - - - 2 changed files: - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types/Constraint.hs Changes: ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -1433,6 +1433,8 @@ decideAndPromoteTyVars top_lvl rhs_tclvl infer_mode name_taus psigs wanted (can_quant_cts, no_quant_cts) = approximateWCX wanted can_quant = ctsPreds can_quant_cts no_quant = ctsPreds no_quant_cts + can_quant_tvs = tyCoVarsOfTypes can_quant + no_quant_tvs = tyCoVarsOfTypes no_quant -- Step 2 of Note [decideAndPromoteTyVars] -- Apply the monomorphism restriction @@ -1448,19 +1450,19 @@ decideAndPromoteTyVars top_lvl rhs_tclvl infer_mode name_taus psigs wanted ++ tau_tys ++ post_mr_quant) co_var_tvs = closeOverKinds co_vars - -- outer_tvs are mentioned in `wanted, and belong to some outer level. + -- outer_tvs are mentioned in `wanted`, and belong to some outer level. -- We definitely can't quantify over them outer_tvs = outerLevelTyVars rhs_tclvl $ - tyCoVarsOfTypes can_quant `unionVarSet` tyCoVarsOfTypes no_quant + can_quant_tvs `unionVarSet` no_quant_tvs -- Step 3 of Note [decideAndPromoteTyVars], (a-c) -- Identify mono_tvs: the type variables that we must not quantify over mono_tvs_without_mr -- This does not work well (#26004) -- | is_top_level = outer_tvs - | otherwise = outer_tvs -- (a) - `unionVarSet` tyCoVarsOfTypes no_quant -- (b) - `unionVarSet` co_var_tvs -- (c) + | otherwise = outer_tvs -- (a) + `unionVarSet` no_quant_tvs -- (b) + `unionVarSet` co_var_tvs -- (c) -- Step 3 of Note [decideAndPromoteTyVars], (d) mono_tvs_with_mr ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -1792,11 +1792,11 @@ approximateWCX wc = case classifyPredType (ctPred ct) of -- See the classification in Note [ApproximateWC] EqPred eq_rel ty1 ty2 - | not encl_eqs -- See Wrinkle (W1) - , quantify_equality eq_rel ty1 ty2 - -> add_to_quant - | otherwise - -> acc -- add_to_no_quant ToDo: never return equalities under an equality + | encl_eqs -> acc + | quantify_equality eq_rel ty1 ty2 -> add_to_quant + | otherwise -> add_to_no_quant + -- encl_eqs: See Wrinkle (W1) + -- ToDo: explain acc ClassPred cls tys | Just {} <- isCallStackPred cls tys @@ -1852,7 +1852,7 @@ We proceed by classifying the constraint: Wrinkle (W1) When inferring most-general types (in simplifyInfer), we - do *not* float an equality constraint if the implication binds + do *not* quantify over equality constraint if the implication binds equality constraints, because that defeats the OutsideIn story. Consider data T a where { TInt :: T Int; MkT :: T a } f TInt = 3::Int View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6cd646c542ede632511448546b2caa... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6cd646c542ede632511448546b2caa... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)