From 7a9d8803cfde3c42da4b27a7b89bdcb2ac870e3f Mon Sep 17 00:00:00 2001 From: sheaf Date: Fri, 30 Jul 2021 13:50:25 +0200 Subject: 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 ------------------------- --- compiler/GHC/Core/Opt/WorkWrap/Utils.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/GHC/Core/Opt/WorkWrap/Utils.hs') diff --git a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs index c3e708c60d..beafa01b1c 100644 --- a/compiler/GHC/Core/Opt/WorkWrap/Utils.hs +++ b/compiler/GHC/Core/Opt/WorkWrap/Utils.hs @@ -30,6 +30,7 @@ import GHC.Core.Type import GHC.Core.Multiplicity import GHC.Core.Predicate ( isClassPred ) import GHC.Core.Coercion +import GHC.Core.Reduction import GHC.Core.FamInstEnv import GHC.Core.TyCon import GHC.Core.TyCon.RecWalk @@ -1239,7 +1240,7 @@ findTypeShape fam_envs ty = TsUnk go_tc rec_tc tc tc_args - | Just (_, rhs, _) <- topReduceTyFamApp_maybe fam_envs tc tc_args + | Just (HetReduction (Reduction _ rhs) _) <- topReduceTyFamApp_maybe fam_envs tc tc_args = go rec_tc rhs | Just con <- tyConSingleAlgDataCon_maybe tc -- cgit v1.2.1