summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Solver/InertSet.hs
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2021-07-30 13:50:25 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-08-04 16:38:40 -0400
commit7a9d8803cfde3c42da4b27a7b89bdcb2ac870e3f (patch)
tree0d2e0dd78e719d93e276fff0a668e8315639ff45 /compiler/GHC/Tc/Solver/InertSet.hs
parent477bc2dd6d506ece1c5c030f79f3934ff1922a5f (diff)
downloadhaskell-7a9d8803cfde3c42da4b27a7b89bdcb2ac870e3f.tar.gz
Use Reductions to keep track of rewritings
We define Reduction = Reduction Coercion !Type. A reduction of the form 'Reduction co new_ty' witnesses an equality ty ~co~> new_ty. That is, the rewriting happens left-to-right: the right-hand-side type of the coercion is the rewritten type, and the left-hand-side type the original type. Sticking to this convention makes the codebase more consistent, helping to avoid certain applications of SymCo. This replaces the parts of the codebase which represented reductions as pairs, (Coercion,Type) or (Type,Coercion). Reduction being strict in the Type argument improves performance in some programs that rewrite many type families (such as T9872). Fixes #20161 ------------------------- Metric Decrease: T5321Fun T9872a T9872b T9872c T9872d -------------------------
Diffstat (limited to 'compiler/GHC/Tc/Solver/InertSet.hs')
-rw-r--r--compiler/GHC/Tc/Solver/InertSet.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Solver/InertSet.hs b/compiler/GHC/Tc/Solver/InertSet.hs
index c5252fb09a..5f41ca4ffd 100644
--- a/compiler/GHC/Tc/Solver/InertSet.hs
+++ b/compiler/GHC/Tc/Solver/InertSet.hs
@@ -36,12 +36,12 @@ import GHC.Prelude
import GHC.Tc.Solver.Types
import GHC.Tc.Types.Constraint
-import GHC.Tc.Types.Evidence
import GHC.Tc.Types.Origin
import GHC.Tc.Utils.TcType
import GHC.Types.Var
import GHC.Types.Var.Env
+import GHC.Core.Reduction
import GHC.Core.Predicate
import GHC.Core.TyCo.FVs
import qualified GHC.Core.TyCo.Rep as Rep
@@ -243,12 +243,12 @@ data InertSet
-- used to undo the cycle-breaking needed to handle
-- Note [Type variable cycles] in GHC.Tc.Solver.Canonical
- , inert_famapp_cache :: FunEqMap (TcCoercion, TcType)
+ , inert_famapp_cache :: FunEqMap Reduction
-- Just a hash-cons cache for use when reducing family applications
-- only
--
-- If F tys :-> (co, rhs, flav),
- -- then co :: rhs ~N F tys
+ -- then co :: F tys ~N rhs
-- all evidence is from instances or Givens; no coercion holes here
-- (We have no way of "kicking out" from the cache, so putting
-- wanteds here means we can end up solving a Wanted with itself. Bad)