add -fsimpleopt-before-flatten
[ghc-hetmet.git] / compiler / basicTypes / VarSet.lhs
index 1bef89a..6f03aad 100644 (file)
@@ -4,32 +4,27 @@
 %
 
 \begin{code}
-{-# OPTIONS -w #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and fix
--- any warnings in the module. See
---     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
--- for details
-
 module VarSet (
+        -- * Var, Id and TyVar set types
        VarSet, IdSet, TyVarSet,
+       
+       -- ** Manipulating these sets
        emptyVarSet, unitVarSet, mkVarSet,
        extendVarSet, extendVarSetList, extendVarSet_C,
        elemVarSet, varSetElems, subVarSet,
        unionVarSet, unionVarSets,
        intersectVarSet, intersectsVarSet, disjointVarSet,
        isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey,
-       minusVarSet, foldVarSet, filterVarSet,
+       minusVarSet, foldVarSet, filterVarSet, fixVarSet,
        lookupVarSet, mapVarSet, sizeVarSet, seqVarSet,
        elemVarSetByKey
     ) where
 
 #include "HsVersions.h"
 
-import Var
+import Var      ( Var, TyVar, Id )
 import Unique
 import UniqSet
-import UniqFM
 \end{code}
 
 %************************************************************************
@@ -68,6 +63,7 @@ extendVarSet_C  :: (Var->Var->Var) -> VarSet -> Var -> VarSet
 
 delVarSetByKey :: VarSet -> Unique -> VarSet
 elemVarSetByKey :: Unique -> VarSet -> Bool
+fixVarSet       :: (VarSet -> VarSet) -> VarSet -> VarSet
 
 emptyVarSet    = emptyUniqSet
 unitVarSet     = unitUniqSet
@@ -105,6 +101,12 @@ elemVarSetByKey    = elemUniqSet_Directly
 intersectsVarSet s1 s2 = not (s1 `disjointVarSet` s2)
 disjointVarSet   s1 s2 = isEmptyVarSet (s1 `intersectVarSet` s2)
 subVarSet        s1 s2 = isEmptyVarSet (s1 `minusVarSet` s2)
+
+-- Iterate f to a fixpoint
+fixVarSet f s | new_s `subVarSet` s = s
+             | otherwise           = fixVarSet f new_s 
+             where
+               new_s = f s
 \end{code}
 
 \begin{code}