[commit: ghc] wip/T14880-accum: Rewrite tyCoVarsOfType in terms of TypeSet (6bf31b3)
git at git.haskell.org
git at git.haskell.org
Tue Sep 4 07:21:56 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T14880-accum
Link : http://ghc.haskell.org/trac/ghc/changeset/6bf31b30781f38518cc73bd8ee9ff452aa05f72b/ghc
>---------------------------------------------------------------
commit 6bf31b30781f38518cc73bd8ee9ff452aa05f72b
Author: Tobias Dammers <tdammers at gmail.com>
Date: Tue Jul 31 22:32:34 2018 +0200
Rewrite tyCoVarsOfType in terms of TypeSet
>---------------------------------------------------------------
6bf31b30781f38518cc73bd8ee9ff452aa05f72b
compiler/types/TyCoRep.hs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index 81cd2b0..9601740 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -1525,7 +1525,15 @@ so, so it's easiest to do it here.
-- synonym.
tyCoVarsOfType :: Type -> TyCoVarSet
-- See Note [Free variables of types]
-tyCoVarsOfType ty = fvVarSet $ tyCoFVsOfType ty
+-- tyCoVarsOfType ty = fvVarSet $ tyCoFVsOfType ty
+tyCoVarsOfType (TyVarTy v) = extendVarSet (tyCoVarsOfType (tyVarKind v)) v
+tyCoVarsOfType (TyConApp _ tys) = tyCoVarsOfTypes tys
+tyCoVarsOfType (LitTy {}) = emptyVarSet
+tyCoVarsOfType (AppTy fun arg) = (tyCoVarsOfType fun `unionVarSet` tyCoVarsOfType arg)
+tyCoVarsOfType (FunTy arg res) = (tyCoVarsOfType arg `unionVarSet` tyCoVarsOfType res)
+tyCoVarsOfType (ForAllTy bndr ty) = tyCoVarSetsBndr bndr (tyCoVarsOfType ty)
+tyCoVarsOfType (CastTy ty co) = (tyCoVarsOfType ty `unionVarSet` tyCoVarsOfCo co)
+tyCoVarsOfType (CoercionTy co) = tyCoVarsOfCo co
-- | `tyCoFVsOfType` that returns free variables of a type in a deterministic
-- set. For explanation of why using `VarSet` is not deterministic see
@@ -1534,6 +1542,11 @@ tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet
-- See Note [Free variables of types]
tyCoVarsOfTypeDSet ty = fvDVarSet $ tyCoFVsOfType ty
+tyCoVarSetsBndr :: TyVarBinder -> VarSet -> VarSet
+-- Free vars of (forall b. <thing with fvs>)
+tyCoVarSetsBndr (TvBndr tv _) fvs = (delVarSet fvs tv)
+ `unionVarSet` tyCoVarsOfType (tyVarKind tv)
+
-- | `tyCoFVsOfType` that returns free variables of a type in deterministic
-- order. For explanation of why using `VarSet` is not deterministic see
-- Note [Deterministic FV] in FV.
More information about the ghc-commits
mailing list