Safe Haskell | Safe |
---|---|

Language | Haskell98 |

Similar to Data.Edison.Coll.EnumSet but it allows to choose the underlying type for bit storage. This is really a low-level module for type-safe foreign function interfaces.

The integer representation of the enumeration type is the bit position of the flag within the bitvector.

- newtype T word index = Cons {
- decons :: word

- fromEnum :: (Enum a, Bits w) => a -> T w a
- fromEnums :: (Enum a, Bits w) => [a] -> T w a
- toEnums :: (Enum a, Bits w) => T w a -> [a]
- intToEnums :: (Enum a, Integral w) => T w a -> [a]
- mostSignificantPosition :: (Bits w, Storable w) => T w a -> Int
- singletonByPosition :: Bits w => Int -> T w a
- null :: (Enum a, Bits w) => T w a -> Bool
- empty :: (Enum a, Bits w) => T w a
- singleton :: (Enum a, Bits w) => a -> T w a
- disjoint :: (Enum a, Bits w) => T w a -> T w a -> Bool
- subset :: (Enum a, Bits w) => T w a -> T w a -> Bool
- (.&.) :: (Enum a, Bits w) => T w a -> T w a -> T w a
- (.-.) :: (Enum a, Bits w) => T w a -> T w a -> T w a
- (.|.) :: (Enum a, Bits w) => T w a -> T w a -> T w a
- xor :: (Enum a, Bits w) => T w a -> T w a -> T w a
- unions :: (Enum a, Bits w) => [T w a] -> T w a
- get :: (Enum a, Bits w) => a -> T w a -> Bool
- put :: (Enum a, Bits w) => a -> Bool -> T w a -> T w a
- accessor :: (Enum a, Bits w) => a -> T (T w a) Bool
- set :: (Enum a, Bits w) => a -> T w a -> T w a
- clear :: (Enum a, Bits w) => a -> T w a -> T w a
- flip :: (Enum a, Bits w) => a -> T w a -> T w a
- fromBool :: (Enum a, Bits w) => a -> Bool -> T w a

# Documentation

Eq word => Eq (T word index) Source # | |

(Enum a, Bits w) => Semigroup (T w a) Source # | |

(Enum a, Bits w) => Monoid (T w a) Source # | Since this data type is intended for constructing flags,
we choose the set union as |

(Enum a, Storable w) => Storable (T w a) Source # | |

mostSignificantPosition :: (Bits w, Storable w) => T w a -> Int Source #

floor of binary logarithm -
Intended for getting the position of a single set bit.
This in turn is intended for implementing an `Enum`

instance
if you only know masks but no bit positions.

singletonByPosition :: Bits w => Int -> T w a Source #

set a bit -
Intended for implementing an `Enum`

instance
if you only know masks but no bit positions.

subset :: (Enum a, Bits w) => T w a -> T w a -> Bool Source #

`subset a b`

is `True`

if `a`

is a subset of `b`

.