X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FVarSet.lhs;h=8cad15e2e80c680a7ec42769c8dde30fe1510f96;hb=bbffa95af87bb66635aaffdaddcd31be063752dc;hp=03ec1ead05f54a80c046d5fbdd914034ad855c2f;hpb=4102e5cec12cd96f59260aee2c6da01616b97467;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/VarSet.lhs b/ghc/compiler/basicTypes/VarSet.lhs index 03ec1ea..8cad15e 100644 --- a/ghc/compiler/basicTypes/VarSet.lhs +++ b/ghc/compiler/basicTypes/VarSet.lhs @@ -5,20 +5,20 @@ \begin{code} module VarSet ( - VarSet, IdSet, TyVarSet, UVarSet, + VarSet, IdSet, TyVarSet, emptyVarSet, unitVarSet, mkVarSet, extendVarSet, extendVarSet_C, elemVarSet, varSetElems, subVarSet, unionVarSet, unionVarSets, intersectVarSet, intersectsVarSet, - isEmptyVarSet, delVarSet, delVarSetByKey, + isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey, minusVarSet, foldVarSet, filterVarSet, lookupVarSet, mapVarSet, sizeVarSet, seqVarSet ) where #include "HsVersions.h" -import Var ( Var, Id, TyVar, UVar ) +import Var ( Var, Id, TyVar ) import Unique ( Unique ) import UniqSet import UniqFM ( delFromUFM_Directly, addToUFM_C ) @@ -34,11 +34,9 @@ import UniqFM ( delFromUFM_Directly, addToUFM_C ) type VarSet = UniqSet Var type IdSet = UniqSet Id type TyVarSet = UniqSet TyVar -type UVarSet = UniqSet UVar 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] @@ -46,6 +44,7 @@ unitVarSet :: Var -> VarSet extendVarSet :: 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 @@ -56,7 +55,6 @@ 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 @@ -65,13 +63,19 @@ emptyVarSet = emptyUniqSet unitVarSet = unitUniqSet extendVarSet = addOneToUniqSet 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 @@ -80,11 +84,16 @@ 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 \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} seqVarSet :: VarSet -> () seqVarSet s = sizeVarSet s `seq` () \end{code}