-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Sets of enumeration values represented by machine words
--
-- With this package you can create a type safe interface to flag sets.
-- It is intended for interfacing to C libraries via FFI, where Word8,
-- Word16, or Word32 types are commonly used to store bit vectors. E.g.
-- the type EnumSet Word16 Ordering represents a flag set stored
-- in a Word16 that supports the flags LT, EQ,
-- GT.
--
-- This package is similar to the bitset package and the
-- Data.Edison.Coll.EnumSet module in the edison
-- package, however our implementation allows you to choose the embedding
-- type and thus the maximum size of the set.
--
-- See also data-flags and Data.EnumSet in
-- enummapset.
@package enumset
@version 0.0.5
-- | 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.
module Data.EnumBitSet
newtype T word index
Cons :: word -> T word index
[decons] :: T word index -> 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]
-- | 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.
mostSignificantPosition :: (Bits w, Storable w) => T w a -> Int
-- | set a bit - Intended for implementing an Enum instance if you
-- only know masks but no bit positions.
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 a b is True if a is a subset of
-- b.
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
infixl 7 .&.
(.-.) :: (Enum a, Bits w) => T w a -> T w a -> T w a
infixl 7 .-.
(.|.) :: (Enum a, Bits w) => T w a -> T w a -> T w a
infixl 5 .|.
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
-- | could also be named member like in Set or
-- elem as in '[]'
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
-- | could also be named insert like in Set
set :: (Enum a, Bits w) => a -> T w a -> T w a
-- | could also be named delete like in Set
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
instance GHC.Classes.Eq word => GHC.Classes.Eq (Data.EnumBitSet.T word index)
instance (GHC.Enum.Enum a, Foreign.Storable.Storable w) => Foreign.Storable.Storable (Data.EnumBitSet.T w a)
instance (GHC.Enum.Enum a, Data.Bits.Bits w) => GHC.Base.Semigroup (Data.EnumBitSet.T w a)
instance (GHC.Enum.Enum a, Data.Bits.Bits w) => GHC.Base.Monoid (Data.EnumBitSet.T w a)
-- | Extract and inject an Enum value into an EnumSet.
-- | Deprecated: use Data.FlagSet instead
module Data.EnumSet.PackedEnum
-- | T w a b describes a contiguous set of bit indices into the
-- word type w where the indices are of type a and the
-- set of indices represent a value of type b.
data T w a b
Cons :: w -> Int -> T w a b
-- | Extract an enumeration value from the specified index set.
unpack :: (Integral w, Bits w, Enum a, Enum b) => T w a b -> T w a -> b
-- | Create an enumeration set, where an value of type b is placed
-- at the specified indices.
pack :: (Num w, Bits w, Enum a, Enum b) => T w a b -> b -> T w a
-- | Clear all bits at the specified indices.
clear :: (Bits w, Enum a, Enum b) => T w a b -> T w a -> T w a
-- | Overwrite an enumset at the specified indices with the value of type
-- b.
put :: (Num w, Bits w, Enum a, Enum b) => T w a b -> b -> T w a -> T w a
-- | The module name clashes with a module from the package
-- enummapset. Thus we will remove this module in favor of
-- Data.EnumBitSet.
-- | Deprecated: use Data.EnumBitSet instead
module Data.EnumSet
-- | A bit vector that represents a record in a bit-packed way.
module Data.FlagSet
-- | The basic bit vector data type. It does not provide a lot of
-- functionality, since that could not be done in a safe way.
--
-- The type a identifies the maintained flags. It may be an
-- empty type but it may also be an enumeration of record fields with
-- concrete values. In the latter case you are encouraged to define an
-- Enum instance for this enumeration. Be aware that it is
-- different from Enum of Prelude.
newtype T word a
Cons :: word -> T word a
[decons] :: T word a -> word
fromMaskedValue :: MaskedValue w a -> T w a
match :: Bits w => T w a -> MaskedValue w a -> Bool
class Enum a
-- | fromEnum should return an integer that represents the position
-- of the a value in the list of all enumeration items. In
-- contrast to that, fromEnum must return the according bit
-- pattern.
fromEnum :: (Enum a, Bits w) => a -> MaskedValue w a
-- | Compose a flag set from a list of flags. However you may prefer to
-- assemble flags using mconcat or mappend on
-- MaskedValues.
compose :: (Enum a, Enum a, Bits w) => [a] -> T w a
-- | Decompose a flag set into flags. The flags are generated using the
-- Bounded and Enum instance. We do not recommend to use
-- the result list for further processing, since testing of flags is much
-- faster using match. However you may find it useful to
-- show the list.
decompose :: (Bounded a, Enum a, Enum a, Bits w) => T w a -> [a]
-- | Mask w a b describes a field of a T w a that has
-- type Value w b. On the machine level a Mask value is a
-- vector of bits, where set bits represent the bits belonging to one
-- record field. There must be only one mask value for every pair of
-- types (a,b).
newtype Mask w a b
Mask :: w -> Mask w a b
[unmask] :: Mask w a b -> w
maskValue :: Mask w a b -> Value w b -> MaskedValue w a
-- | The type parameter w is the type of the underlying bit
-- vector. The type parameter b is a phantom type, that is
-- specific for a certain range of bits.
newtype Value w b
Value :: w -> Value w b
[unvalue] :: Value w b -> w
-- | Combines a mask with a value, that matches this mask. In
-- MaskedValue mask value, value must be a subset of
-- mask.
data MaskedValue w a
MaskedValue :: w -> w -> MaskedValue w a
get :: (Enum a, Bits w) => Mask w a b -> T w a -> Value w b
-- | All bits in Value must be contained in the mask. This condition is not
-- checked by put.
--
-- According to names in Data.Accessor it should be called
-- set, but in Data.Bits and thus Data.EnumSet
-- this is already used in the pair set/clear.
-- put/get resembles the pair in
-- Control.Monad.State in the mtl package.
put :: (Enum a, Bits w) => Mask w a b -> Value w b -> T w a -> T w a
accessor :: (Enum a, Bits w) => Mask w a b -> T (T w a) (Value w b)
instance GHC.Show.Show w => GHC.Show.Show (Data.FlagSet.MaskedValue w a)
instance GHC.Classes.Eq w => GHC.Classes.Eq (Data.FlagSet.MaskedValue w a)
instance GHC.Show.Show w => GHC.Show.Show (Data.FlagSet.Value w b)
instance GHC.Classes.Eq w => GHC.Classes.Eq (Data.FlagSet.Value w b)
instance GHC.Show.Show w => GHC.Show.Show (Data.FlagSet.Mask w a b)
instance GHC.Classes.Eq w => GHC.Classes.Eq (Data.FlagSet.Mask w a b)
instance GHC.Classes.Eq word => GHC.Classes.Eq (Data.FlagSet.T word a)
instance Data.Bits.Bits w => GHC.Base.Semigroup (Data.FlagSet.MaskedValue w a)
instance Data.Bits.Bits w => GHC.Base.Monoid (Data.FlagSet.MaskedValue w a)
instance Foreign.Storable.Storable w => Foreign.Storable.Storable (Data.FlagSet.T w a)
module Data.FlagSet.PackedRecord
getIntByMask :: (Bits w, Integral w, Integral i) => Mask w a b -> T w a -> i
putIntByMask :: (Bits w, Integral w, Integral i) => Mask w a b -> i -> T w a -> T w a
accessorIntByMask :: (Bits w, Integral w, Integral i) => Mask w a b -> T (T w a) i
getIntByRange :: (Bits w, Integral w, Integral i) => Int -> Int -> T w a -> i
putIntByRange :: (Bits w, Integral w, Integral i) => Int -> Int -> i -> T w a -> T w a
accessorIntByRange :: (Bits w, Integral w, Integral i) => Int -> Int -> T (T w a) i