X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FVarSet.lhs;h=55e82a8515ae17871946e676343a1ed94dbeb249;hb=0c53bd0e1b02dea0bde32cd7eb8ccb5ee2d3719e;hp=e90ed25d7964977aea343b1d9b1a330f5a8f0be4;hpb=bca9dd54c2b39638cb4638aaccf6015a104a1df5;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/VarSet.lhs b/ghc/compiler/basicTypes/VarSet.lhs index e90ed25..55e82a8 100644 --- a/ghc/compiler/basicTypes/VarSet.lhs +++ b/ghc/compiler/basicTypes/VarSet.lhs @@ -7,13 +7,14 @@ module VarSet ( VarSet, IdSet, TyVarSet, emptyVarSet, unitVarSet, mkVarSet, - extendVarSet, extendVarSet_C, + extendVarSet, extendVarSetList, extendVarSet_C, elemVarSet, varSetElems, subVarSet, unionVarSet, unionVarSets, intersectVarSet, intersectsVarSet, - isEmptyVarSet, delVarSet, delVarSetByKey, + isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey, minusVarSet, foldVarSet, filterVarSet, - lookupVarSet, mapVarSet, sizeVarSet, seqVarSet + lookupVarSet, mapVarSet, sizeVarSet, seqVarSet, + elemVarSetByKey ) where #include "HsVersions.h" @@ -37,14 +38,15 @@ type TyVarSet = UniqSet TyVar emptyVarSet :: VarSet intersectVarSet :: VarSet -> VarSet -> VarSet -intersectsVarSet:: VarSet -> VarSet -> Bool -- True if non-empty intersection unionVarSet :: VarSet -> VarSet -> VarSet unionVarSets :: [VarSet] -> VarSet varSetElems :: VarSet -> [Var] unitVarSet :: Var -> VarSet extendVarSet :: VarSet -> Var -> VarSet +extendVarSetList:: VarSet -> [Var] -> VarSet elemVarSet :: Var -> VarSet -> Bool delVarSet :: VarSet -> Var -> VarSet +delVarSetList :: VarSet -> [Var] -> VarSet minusVarSet :: VarSet -> VarSet -> VarSet isEmptyVarSet :: VarSet -> Bool mkVarSet :: [Var] -> VarSet @@ -55,22 +57,29 @@ lookupVarSet :: VarSet -> Var -> Maybe Var mapVarSet :: (Var -> Var) -> VarSet -> VarSet sizeVarSet :: VarSet -> Int filterVarSet :: (Var -> Bool) -> VarSet -> VarSet -subVarSet :: VarSet -> VarSet -> Bool extendVarSet_C :: (Var->Var->Var) -> VarSet -> Var -> VarSet delVarSetByKey :: VarSet -> Unique -> VarSet +elemVarSetByKey :: Unique -> VarSet -> Bool emptyVarSet = emptyUniqSet unitVarSet = unitUniqSet extendVarSet = addOneToUniqSet +extendVarSetList= addListToUniqSet intersectVarSet = intersectUniqSets -intersectsVarSet s1 s2 = not (isEmptyVarSet (s1 `intersectVarSet` s2)) + +intersectsVarSet:: VarSet -> VarSet -> Bool -- True if non-empty intersection + -- (s1 `intersectsVarSet` s2) doesn't compute s2 if s1 is empty +subVarSet :: VarSet -> VarSet -> Bool -- True if first arg is subset of second + -- (s1 `subVarSet` s2) doesn't compute s2 if s1 is empty + unionVarSet = unionUniqSets unionVarSets = unionManyUniqSets varSetElems = uniqSetToList elemVarSet = elementOfUniqSet minusVarSet = minusUniqSet delVarSet = delOneFromUniqSet +delVarSetList = delListFromUniqSet isEmptyVarSet = isEmptyUniqSet mkVarSet = mkUniqSet foldVarSet = foldUniqSet @@ -79,8 +88,14 @@ mapVarSet = mapUniqSet sizeVarSet = sizeUniqSet filterVarSet = filterUniqSet extendVarSet_C combine s x = addToUFM_C combine s x x -a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b) delVarSetByKey = delFromUFM_Directly -- Can't be bothered to add this to UniqSet +elemVarSetByKey = elemUniqSet_Directly +\end{code} + +\begin{code} +-- See comments with type signatures +intersectsVarSet s1 s2 = not (isEmptyVarSet (s1 `intersectVarSet` s2)) +a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b) \end{code} \begin{code}