diff options
author | sheaf <sam.derbyshire@gmail.com> | 2021-07-30 13:50:25 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-08-04 16:38:40 -0400 |
commit | 7a9d8803cfde3c42da4b27a7b89bdcb2ac870e3f (patch) | |
tree | 0d2e0dd78e719d93e276fff0a668e8315639ff45 /compiler/GHC/Tc/Plugin.hs | |
parent | 477bc2dd6d506ece1c5c030f79f3934ff1922a5f (diff) | |
download | haskell-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/Plugin.hs')
-rw-r--r-- | compiler/GHC/Tc/Plugin.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/GHC/Tc/Plugin.hs b/compiler/GHC/Tc/Plugin.hs index 0674f69903..78a0ebd16a 100644 --- a/compiler/GHC/Tc/Plugin.hs +++ b/compiler/GHC/Tc/Plugin.hs @@ -67,13 +67,14 @@ import GHC.Tc.Utils.Monad ( TcGblEnv, TcLclEnv, TcPluginM import GHC.Tc.Types.Constraint ( Ct, CtLoc, CtEvidence(..), ctLocOrigin ) import GHC.Tc.Utils.TcMType ( TcTyVar, TcType ) import GHC.Tc.Utils.Env ( TcTyThing ) -import GHC.Tc.Types.Evidence ( TcCoercion, CoercionHole, EvTerm(..) +import GHC.Tc.Types.Evidence ( CoercionHole, EvTerm(..) , EvExpr, EvBind, mkGivenEvBind ) import GHC.Types.Var ( EvVar ) import GHC.Unit.Module import GHC.Types.Name import GHC.Types.TyThing +import GHC.Core.Reduction ( Reduction ) import GHC.Core.TyCon import GHC.Core.DataCon import GHC.Core.Class @@ -142,7 +143,7 @@ getFamInstEnvs :: TcPluginM (FamInstEnv, FamInstEnv) getFamInstEnvs = unsafeTcPluginTcM TcM.tcGetFamInstEnvs matchFam :: TyCon -> [Type] - -> TcPluginM (Maybe (TcCoercion, TcType)) + -> TcPluginM (Maybe Reduction) matchFam tycon args = unsafeTcPluginTcM $ TcS.matchFamTcM tycon args newUnique :: TcPluginM Unique |