#elif defined(__YALE_HASKELL__)
{-hide import from mkdependHS-}
import
- LogOpPrims
+ LogOpPrims
#else
{-hide import from mkdependHS-}
import
data BitSet = MkBS Word#
-emptyBS :: BitSet
+emptyBS :: BitSet
emptyBS = MkBS (int2Word# 0#)
mkBS :: [Int] -> BitSet
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s#) =
+isEmptyBS (MkBS s#) =
case word2Int# s# of
0# -> True
_ -> False
listBS :: BitSet -> [Int]
listBS s = listify s 0
- where listify (MkBS s#) n =
+ where listify (MkBS s#) n =
case word2Int# s# of
0# -> []
_ -> let s' = (MkBS (s# `shiftr` 1#))
in case word2Int# (s# `and#` (int2Word# 1#)) of
0# -> more
_ -> n : more
-# if __GLASGOW_HASKELL__ >= 23
shiftr x y = shiftRL# x y
-# else
- shiftr x y = shiftR# x y
-# endif
#elif defined(__YALE_HASKELL__)
data BitSet = MkBS Int
-emptyBS :: BitSet
+emptyBS :: BitSet
emptyBS = MkBS 0
mkBS :: [Int] -> BitSet
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s) =
+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) =
+elementBS x (MkBS s) =
case logbitpInt x s of
0 -> False
_ -> True
minusBS :: BitSet -> BitSet -> BitSet
minusBS (MkBS x) (MkBS y) = MkBS (x `logandc2Int` y)
--- rewritten to avoid right shifts (which would give nonsense on negative
+-- rewritten to avoid right shifts (which would give nonsense on negative
-- values.
listBS :: BitSet -> [Int]
listBS (MkBS s) = listify s 0 1
- where listify s n m =
+ where listify s n m =
case s of
0 -> []
_ -> let n' = n+1; m' = m+m in
- case logbitpInt s m of
+ case logbitpInt s m of
0 -> listify s n' m'
_ -> n : listify (s `logandc2Int` m) n' m'
-#else /* HBC, perhaps? */
+#else /* HBC, perhaps? */
data BitSet = MkBS Word
-emptyBS :: BitSet
+emptyBS :: BitSet
emptyBS = MkBS 0
mkBS :: [Int] -> BitSet
#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
-isEmptyBS (MkBS s) =
+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) =
+elementBS x (MkBS s) =
case (1 `bitLsh` x) `bitAnd` s of
0 -> False
_ -> True
listBS :: BitSet -> [Int]
listBS (MkBS s) = listify s 0
- where listify s n =
+ where listify s n =
case s of
0 -> []
_ -> let s' = s `bitRsh` 1