[Git][ghc/ghc][wip/T23070-unify] Wibble
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Fri Apr 28 17:06:12 UTC 2023
Simon Peyton Jones pushed to branch wip/T23070-unify at Glasgow Haskell Compiler / GHC
Commits:
525f107c by Simon Peyton Jones at 2023-04-28T18:07:46+01:00
Wibble
- - - - -
2 changed files:
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Types/Constraint.hs
Changes:
=====================================
compiler/GHC/Tc/Solver/Monad.hs
=====================================
@@ -1967,11 +1967,14 @@ Note [wrapUnifierTcS]
When decomposing equalities we often create new wanted constraints for
(s ~ t). But what if s=t? Then it'd be faster to return Refl right away.
-Rather than making an equality test (which traverses the structure of
-the type, perhaps fruitlessly), we call uType (via wrapUnifierTcS) to
-traverse the common structure, and bales out when it finds a
-difference by creating a new Wanted constraint. But where it succeeds
-in finding common structure, it just builds a coercion to reflect it.
+Rather than making an equality test (which traverses the structure of the type,
+perhaps fruitlessly), we call uType (via wrapUnifierTcS) to traverse the common
+structure, and bales out when it finds a difference by creating a new deferred
+Wanted constraint. But where it succeeds in finding common structure, it just
+builds a coercion to reflect it.
+
+This is all much faster than creating a new constraint, putting it in the
+work list, picking it out, canonicalising it, etc etc.
Note [unifyFunDeps]
~~~~~~~~~~~~~~~~~~~
@@ -2003,14 +2006,14 @@ unifyFunDeps ev role do_unifications
wrapUnifierTcS :: CtEvidence -> Role
-> (UnifyEnv -> TcM a) -- Some calls to uType
-> TcS (a, Bag Ct, [TcTyVar])
--- Return coercions witnessing the equality of the two types,
--- emitting new work equalities where necessary to achieve that
+-- Invokes the do_unifications argument, with a suitable UnifyEnv.
+-- Emit deferred equalities and kick-out from the inert set as a
+-- result of any unifications.
-- Very good short-cut when the two types are equal, or nearly so
-- See Note [wrapUnifierTcS]
--- The returned coercion's role matches the input parameter
--
--- The [TcTyVar] is the list of unification variables
--- that were unified the process.
+-- The [TcTyVar] is the list of unification variables that were
+-- unified the process; the (Bag Ct) are the deferred constraints.
wrapUnifierTcS ev role do_unifications
= do { (cos, unified, rewriters, cts) <- wrapTcS $
=====================================
compiler/GHC/Tc/Types/Constraint.hs
=====================================
@@ -247,7 +247,7 @@ and that can be used to rewrite other constrtaints. It satisfies these invariant
* (TyEq:U) An EqCt is not immediately unifiable. If we can unify a:=ty, we
will not form an EqCt (a ~ ty).
* (TyEq:CH) rhs does not mention any coercion holes that resulted from fixing up
- a hetero-kinded equality. See Note [Equalites with incompatible kinds] in
+ a hetero-kinded equality. See Note [Equalities with incompatible kinds] in
GHC.Tc.Solver.Equality
These invariants ensure that the EqCts in inert_eqs constitute a terminating
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/525f107c99eff62938f216973f5253d87f3dc57b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/525f107c99eff62938f216973f5253d87f3dc57b
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/20230428/e65344bf/attachment-0001.html>
More information about the ghc-commits
mailing list