|
25 | 25 | -- independent of container choice, the maximum number of elements in a |
26 | 26 | -- bit set is bounded by @maxBound :: Int@. |
27 | 27 |
|
| 28 | +{-# LANGUAGE BangPatterns #-} |
28 | 29 | {-# LANGUAGE CPP #-} |
| 30 | +{-# LANGUAGE DeriveDataTypeable #-} |
29 | 31 | {-# LANGUAGE GADTs #-} |
30 | | -{-# LANGUAGE BangPatterns #-} |
31 | 32 | {-# LANGUAGE NamedFieldPuns #-} |
32 | | -{-# LANGUAGE DeriveDataTypeable #-} |
33 | 33 |
|
34 | 34 | module Data.BitSet.Generic |
35 | 35 | ( |
@@ -92,16 +92,14 @@ import qualified Data.Foldable as Foldable |
92 | 92 | import qualified Data.List as List |
93 | 93 |
|
94 | 94 | -- | A bit set with unspecified container type. |
95 | | -data GBitSet c a = |
96 | | - (Enum a, Bits c, Num c) => |
97 | | - BitSet { _n :: {-# UNPACK #-} !Int -- ^ Number of elements in the bit set. |
| 95 | +data GBitSet c a = (Enum a, Bits c, Num c) => BitSet |
| 96 | + { _n :: {-# UNPACK #-} !Int -- ^ Number of elements in the bit set. |
98 | 97 | #if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 708) |
99 | | - , _bits :: {-# UNPACK #-} !c -- ^ Bit container. |
| 98 | + , _bits :: {-# UNPACK #-} !c -- ^ Bit container. |
100 | 99 | #else |
101 | | - , _bits :: !c -- ^ Bit container. |
| 100 | + , _bits :: !c -- ^ Bit container. |
102 | 101 | #endif |
103 | | - } |
104 | | - deriving Typeable |
| 102 | + } deriving Typeable |
105 | 103 |
|
106 | 104 | instance Eq c => Eq (GBitSet c a) where |
107 | 105 | BitSet { _n = n1, _bits = b1 } == BitSet { _n = n2, _bits = b2 } = |
@@ -165,12 +163,12 @@ member :: (Enum a , Bits c) => a -> GBitSet c a -> Bool |
165 | 163 | member x = (`testBit` fromEnum x) . _bits |
166 | 164 | {-# INLINE member #-} |
167 | 165 |
|
168 | | --- | /O(d)/. Ask whether the item is in the bit set. |
| 166 | +-- | /O(d)/. Ask whether the item is not in the bit set. |
169 | 167 | notMember :: (Enum a, Bits c) => a -> GBitSet c a -> Bool |
170 | 168 | notMember x = not . member x |
171 | 169 | {-# INLINE notMember #-} |
172 | 170 |
|
173 | | --- | /O(max(n, m))/. Is this a subset? (@s1 isSubsetOf s2@) tells whether |
| 171 | +-- | /O(max(n, m))/. Is this a subset? (@s1 `isSubsetOf` s2@) tells whether |
174 | 172 | -- @s1@ is a subset of @s2@. |
175 | 173 | isSubsetOf :: GBitSet c a -> GBitSet c a -> Bool |
176 | 174 | isSubsetOf (BitSet { _n = n1, _bits = b1 }) (BitSet { _n = n2, _bits = b2 }) = |
|
0 commit comments