module BitSet (
BitSet, -- abstract type
- mkBS, listBS, emptyBS, singletonBS,
+ mkBS, listBS, emptyBS, unitBS,
unionBS, minusBS
#if ! defined(COMPILING_GHC)
, elementBS, intersectBS, isEmptyBS
emptyBS = MkBS (int2Word# 0#)
mkBS :: [Int] -> BitSet
-mkBS xs = foldr (unionBS . singletonBS) emptyBS xs
+mkBS xs = foldr (unionBS . unitBS) emptyBS xs
-singletonBS :: Int -> BitSet
-singletonBS x = case x of
+unitBS :: Int -> BitSet
+unitBS x = case x of
I# i# -> MkBS ((int2Word# 1#) `shiftL#` i#)
unionBS :: BitSet -> BitSet -> BitSet
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s#) =
- case word2Int# s# of
+isEmptyBS (MkBS s#)
+ = case word2Int# s# of
0# -> True
_ -> False
emptyBS = MkBS 0
mkBS :: [Int] -> BitSet
-mkBS xs = foldr (unionBS . singletonBS) emptyBS xs
+mkBS xs = foldr (unionBS . unitBS) emptyBS xs
-singletonBS :: Int -> BitSet
-singletonBS x = MkBS (1 `ashInt` x)
+unitBS :: Int -> BitSet
+unitBS x = MkBS (1 `ashInt` x)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `logiorInt` y)
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s) =
- case s of
+isEmptyBS (MkBS s)
+ = case s of
0 -> True
_ -> False
intersectBS (MkBS x) (MkBS y) = MkBS (x `logandInt` y)
elementBS :: Int -> BitSet -> Bool
-elementBS x (MkBS s) =
- case logbitpInt x s of
+elementBS x (MkBS s)
+ = case logbitpInt x s of
0 -> False
_ -> True
#endif
emptyBS = MkBS 0
mkBS :: [Int] -> BitSet
-mkBS xs = foldr (unionBS . singletonBS) emptyBS xs
+mkBS xs = foldr (unionBS . unitBS) emptyBS xs
-singletonBS :: Int -> BitSet
-singletonBS x = MkBS (1 `bitLsh` x)
+unitBS :: Int -> BitSet
+unitBS x = MkBS (1 `bitLsh` x)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `bitOr` y)
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s) =
- case s of
+isEmptyBS (MkBS s)
+ = case s of
0 -> True
_ -> False
intersectBS (MkBS x) (MkBS y) = MkBS (x `bitAnd` y)
elementBS :: Int -> BitSet -> Bool
-elementBS x (MkBS s) =
- case (1 `bitLsh` x) `bitAnd` s of
+elementBS x (MkBS s)
+ = case (1 `bitLsh` x) `bitAnd` s of
0 -> False
_ -> True
#endif