%
-% (c) The GRASP Project, Glasgow University, 1994-1995
+% (c) The GRASP Project, Glasgow University, 1994-1998
%
\section[BitSet]{An implementation of very small sets}
module BitSet (
BitSet, -- abstract type
mkBS, listBS, emptyBS, unitBS,
- unionBS, minusBS
+ unionBS, minusBS, intBS
) where
+#include "HsVersions.h"
+
#ifdef __GLASGOW_HASKELL__
-#if __GLASGOW_HASKELL__ >= 202
-import GlaExts
-#endif
+import GLAEXTS
-- nothing to import
#elif defined(__YALE_HASKELL__)
{-hide import from mkdependHS-}
unitBS :: Int -> BitSet
unitBS x = case x of
+#if __GLASGOW_HASKELL__ >= 503
+ I# i# -> MkBS ((int2Word# 1#) `uncheckedShiftL#` i#)
+#else
I# i# -> MkBS ((int2Word# 1#) `shiftL#` i#)
+#endif
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x#) (MkBS y#) = MkBS (x# `or#` y#)
in case word2Int# (s# `and#` (int2Word# 1#)) of
0# -> more
_ -> n : more
+#if __GLASGOW_HASKELL__ >= 503
+ shiftr x y = uncheckedShiftRL# x y
+#else
shiftr x y = shiftRL# x y
+#endif
+
+-- intBS is a bit naughty.
+intBS :: BitSet -> Int
+intBS (MkBS w#) = I# (word2Int# w#)
#elif defined(__YALE_HASKELL__)