Commit 71de34ed authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Add new VarEnv functions minusVarEnv, intersectsVarEnv, unionInScope

parent 8657bb00
...@@ -14,6 +14,7 @@ module VarEnv ( ...@@ -14,6 +14,7 @@ module VarEnv (
extendVarEnv, extendVarEnv_C, extendVarEnv_Acc, extendVarEnvList, extendVarEnv, extendVarEnv_C, extendVarEnv_Acc, extendVarEnvList,
plusVarEnv, plusVarEnv_C, plusVarEnv, plusVarEnv_C,
delVarEnvList, delVarEnv, delVarEnvList, delVarEnv,
minusVarEnv, intersectsVarEnv,
lookupVarEnv, lookupVarEnv_NF, lookupWithDefaultVarEnv, lookupVarEnv, lookupVarEnv_NF, lookupWithDefaultVarEnv,
mapVarEnv, zipVarEnv, mapVarEnv, zipVarEnv,
modifyVarEnv, modifyVarEnv_Directly, modifyVarEnv, modifyVarEnv_Directly,
...@@ -28,7 +29,7 @@ module VarEnv ( ...@@ -28,7 +29,7 @@ module VarEnv (
emptyInScopeSet, mkInScopeSet, delInScopeSet, emptyInScopeSet, mkInScopeSet, delInScopeSet,
extendInScopeSet, extendInScopeSetList, extendInScopeSetSet, extendInScopeSet, extendInScopeSetList, extendInScopeSetSet,
getInScopeVars, lookupInScope, lookupInScope_Directly, getInScopeVars, lookupInScope, lookupInScope_Directly,
elemInScopeSet, uniqAway, unionInScope, elemInScopeSet, uniqAway,
-- * The RnEnv2 type -- * The RnEnv2 type
RnEnv2, RnEnv2,
...@@ -120,6 +121,10 @@ lookupInScope (InScope in_scope _) v = lookupVarEnv in_scope v ...@@ -120,6 +121,10 @@ lookupInScope (InScope in_scope _) v = lookupVarEnv in_scope v
lookupInScope_Directly :: InScopeSet -> Unique -> Maybe Var lookupInScope_Directly :: InScopeSet -> Unique -> Maybe Var
lookupInScope_Directly (InScope in_scope _) uniq lookupInScope_Directly (InScope in_scope _) uniq
= lookupVarEnv_Directly in_scope uniq = lookupVarEnv_Directly in_scope uniq
unionInScope :: InScopeSet -> InScopeSet -> InScopeSet
unionInScope (InScope s1 _) (InScope s2 n2)
= InScope (s1 `plusVarEnv` s2) n2
\end{code} \end{code}
\begin{code} \begin{code}
...@@ -352,6 +357,8 @@ filterVarEnv_Directly :: (Unique -> a -> Bool) -> VarEnv a -> VarEnv a ...@@ -352,6 +357,8 @@ filterVarEnv_Directly :: (Unique -> a -> Bool) -> VarEnv a -> VarEnv a
restrictVarEnv :: VarEnv a -> VarSet -> VarEnv a restrictVarEnv :: VarEnv a -> VarSet -> VarEnv a
delVarEnvList :: VarEnv a -> [Var] -> VarEnv a delVarEnvList :: VarEnv a -> [Var] -> VarEnv a
delVarEnv :: VarEnv a -> Var -> VarEnv a delVarEnv :: VarEnv a -> Var -> VarEnv a
minusVarEnv :: VarEnv a -> VarEnv a -> VarEnv a
intersectsVarEnv :: VarEnv a -> VarEnv a -> Bool
plusVarEnv_C :: (a -> a -> a) -> VarEnv a -> VarEnv a -> VarEnv a plusVarEnv_C :: (a -> a -> a) -> VarEnv a -> VarEnv a -> VarEnv a
mapVarEnv :: (a -> b) -> VarEnv a -> VarEnv b mapVarEnv :: (a -> b) -> VarEnv a -> VarEnv b
modifyVarEnv :: (a -> a) -> VarEnv a -> Var -> VarEnv a modifyVarEnv :: (a -> a) -> VarEnv a -> Var -> VarEnv a
...@@ -377,6 +384,8 @@ extendVarEnvList = addListToUFM ...@@ -377,6 +384,8 @@ extendVarEnvList = addListToUFM
plusVarEnv_C = plusUFM_C plusVarEnv_C = plusUFM_C
delVarEnvList = delListFromUFM delVarEnvList = delListFromUFM
delVarEnv = delFromUFM delVarEnv = delFromUFM
minusVarEnv = minusUFM
intersectsVarEnv e1 e2 = not (isEmptyVarEnv (e1 `intersectUFM` e2))
plusVarEnv = plusUFM plusVarEnv = plusUFM
lookupVarEnv = lookupUFM lookupVarEnv = lookupUFM
lookupWithDefaultVarEnv = lookupWithDefaultUFM lookupWithDefaultVarEnv = lookupWithDefaultUFM
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment