[Git][ghc/ghc][wip/T22194-flags] Never quantify over equalities in an inferred type

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Wed Mar 29 12:18:54 UTC 2023



Simon Peyton Jones pushed to branch wip/T22194-flags at Glasgow Haskell Compiler / GHC


Commits:
312b3975 by Simon Peyton Jones at 2023-03-29T13:18:48+01:00
Never quantify over equalities in an inferred type

An experiment.. trying to do the Right Thing!

Examples
* #22194
* `histogram_` in Statistics.Sample.Histogram in `statistics`

- - - - -


1 changed file:

- compiler/GHC/Tc/Solver.hs


Changes:

=====================================
compiler/GHC/Tc/Solver.hs
=====================================
@@ -1809,18 +1809,26 @@ decidePromotedTyVars infer_mode name_taus psigs candidates
     pick :: InferMode -> [PredType] -> TcM ([PredType], [PredType])
     -- Split the candidates into ones we definitely
     -- won't quantify, and ones that we might
-    pick NoRestrictions  cand = return ([], cand)
     pick ApplyMR         cand = return (cand, [])
+    pick NoRestrictions  cand = return (partition is_eq cand)
     pick EagerDefaulting cand = do { os <- xoptM LangExt.OverloadedStrings
                                    ; return (partition (is_int_ct os) cand) }
 
     -- For EagerDefaulting, do not quantify over
     -- over any interactive class constraint
     is_int_ct ovl_strings pred
-      | Just (cls, _) <- getClassPredTys_maybe pred
-      = isInteractiveClass ovl_strings cls
-      | otherwise
-      = False
+      = case classifyPredType pred of
+           ClassPred cls _ -> isInteractiveClass ovl_strings cls
+           EqPred {}       -> True
+           IrredPred {}    -> True
+           ForAllPred {}   -> True
+
+    is_eq pred
+      = case classifyPredType pred of
+           ClassPred {}  -> False
+           EqPred {}     -> True
+           IrredPred {}  -> True
+           ForAllPred {} -> True
 
 -------------------
 defaultTyVarsAndSimplify :: TcLevel



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/312b39757c5af257985a72d2f29ebed803bc8722

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/312b39757c5af257985a72d2f29ebed803bc8722
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230329/93feb3c0/attachment-0001.html>


More information about the ghc-commits mailing list