[project @ 2001-04-26 12:16:57 by simonmar]
[ghc-hetmet.git] / ghc / compiler / basicTypes / VarSet.lhs
index 261426e..a3c55f4 100644 (file)
@@ -5,9 +5,9 @@
 
 \begin{code}
 module VarSet (
-       VarSet, IdSet, TyVarSet, UVarSet,
+       VarSet, IdSet, TyVarSet,
        emptyVarSet, unitVarSet, mkVarSet,
-       extendVarSet,
+       extendVarSet, extendVarSet_C,
        elemVarSet, varSetElems, subVarSet,
        unionVarSet, unionVarSets,
        intersectVarSet, intersectsVarSet,
@@ -18,12 +18,10 @@ module VarSet (
 
 #include "HsVersions.h"
 
-import CmdLineOpts     ( opt_PprStyle_Debug )
-import Var             ( Var, Id, TyVar, UVar, setVarUnique )
-import Unique          ( Unique, Uniquable(..) )
+import Var             ( Var, Id, TyVar )
+import Unique          ( Unique )
 import UniqSet
-import UniqFM          ( delFromUFM_Directly )
-import Outputable
+import UniqFM          ( delFromUFM_Directly, addToUFM_C )
 \end{code}
 
 %************************************************************************
@@ -36,11 +34,9 @@ import Outputable
 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]
@@ -58,7 +54,7 @@ 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
 
@@ -66,7 +62,12 @@ 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
@@ -80,11 +81,17 @@ lookupVarSet        = lookupUniqSet
 mapVarSet      = mapUniqSet
 sizeVarSet     = sizeUniqSet
 filterVarSet   = filterUniqSet
-a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b)
+extendVarSet_C combine s x = addToUFM_C combine s x x
 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}