Simon Peyton Jones pushed to branch wip/T26543b at Glasgow Haskell Compiler / GHC Commits: 3ffab1d9 by Simon Peyton Jones at 2026-10-12T10:32:38+01:00 Remove unnecessary use of FV in foldQLInstVars - - - - - 2 changed files: - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Tc/Gen/App.hs Changes: ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -44,7 +44,7 @@ import Control.Monad ( zipWithM ) This module does coercion optimisation. See the paper - Evidence normalization in Systtem FV (RTA'13) + Evidence normalization in System FV (RTA'13) https://simon.peytonjones.org/evidence-normalization/ The paper is also in the GHC repo, in docs/opt-coercion. ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -48,7 +48,6 @@ import GHC.Builtin.PrimOps( tagToEnumKey ) import GHC.Builtin.KnownKeys import GHC.Types.Var -import GHC.Types.Var.FV import GHC.Types.Name import GHC.Types.Name.Env import GHC.Types.Name.Reader @@ -2117,6 +2116,8 @@ anyFreeKappa :: TcType -> TcM Bool -- See Note [The fiv test in quickLookArg] anyFreeKappa ty = unTcMBool (foldQLInstVars go_tv ty) where + go_tv :: TcTyVar -> TcMBool + -- `tv` is an instantiation variable go_tv tv = TCMB $ do { info <- readMetaTyVar tv ; case info of Indirect ty -> anyFreeKappa ty @@ -2129,13 +2130,15 @@ instance Monoid TcMBool where mempty = TCMB (return False) foldQLInstVars :: forall a. Monoid a => (TcTyVar -> a) -> TcType -> a +-- Given (foldQLInstVars p ty), find all the free shallow instantiation +-- variables, apply `p` to them, and combine with `mappend`. {-# INLINE foldQLInstVars #-} foldQLInstVars check_tv ty - = runFV (do_ty ty) () + = do_ty ty where (do_ty, _, _, _) = foldTyCo folder - folder :: TyCoFolder (FV () a) + folder :: TyCoFolder a folder = TyCoFolder { tcf_view = noView -- See Note [Free vars and synonyms] -- in GHC.Core.TyCo.FVs , tcf_tyvar = do_tv, tcf_covar = mempty @@ -2146,8 +2149,8 @@ foldQLInstVars check_tv ty do_hole hole = do_ty (coVarKind (coHoleCoVar hole)) -- See (MIV2) in Note [Monomorphise instantiation variables] - do_tv :: TcTyVar -> FV () a - do_tv tv | isQLInstTyVar tv = MkFV $ \_ -> check_tv tv + do_tv :: TcTyVar -> a + do_tv tv | isQLInstTyVar tv = check_tv tv | otherwise = mempty {- ********************************************************************* View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ffab1d97c53032a52a0a6e48728ec67... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ffab1d97c53032a52a0a6e48728ec67... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help