-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A bit array (aka bitset, bitmap, bit vector) API for numeric types -- -- The library extends the numeric types with an array-like interface -- over individual set bits. It also provides an API for conversion to -- and from the binary notation. @package bit-array @version 0.1.1 module BitArray -- | A newtype wrapper which provides an array-like interface to a -- type, which has instances of Bits, FiniteBits and -- Num. -- -- You can construct bit arrays by wrapping numeric values: -- --
-- >>> BitArray (7 :: Int8) -- [qq|00000111|] ---- -- or directly from numeric literals: -- --
-- >>> 7 :: BitArray Int8 -- [qq|00000111|] ---- -- or using a binary notation quasi-quoter, assuming you have the -- QuasiQuotes pragma turned on: -- --
-- >>> [qq|0111|] :: BitArray Int8 -- [qq|00000111|] ---- -- BitArray derives the Bits and FiniteBits -- instances from the base type, so it supports all the standard bitwise -- operations for fixed-size integral types. newtype BitArray a BitArray :: a -> BitArray a -- | Produces a literal of zeros and ones. -- --
-- >>> show (BitArray (5 :: Int8)) -- "[qq|00000101|]" ---- | Parses a literal of zeros and ones. -- --
-- >>> read "[qq|1110|]" :: BitArray Int8 -- [qq|00001110|] ---- --
-- >>> unwrap (read "[qq|1110|]") :: Int -- 14 ---- | A binary number quasi-quoter. Produces a numeric literal at compile -- time. Can be used to construct both bit arrays and integral numbers. -- --
-- >>> [qq|011|] :: Int -- 3 ---- --
-- >>> [qq|011|] :: BitArray Int8 -- [qq|00000011|] --qq :: QuasiQuoter -- | Unwrap the underlying value of a bit array. unwrap :: BitArray a -> a -- | Convert into a binary notation string. -- --
-- >>> toString (BitArray (5 :: Int8)) -- "00000101" --toString :: (FiniteBits a) => BitArray a -> String -- | Parse a binary notation string. -- --
-- >>> parseString "123" :: Maybe (BitArray Int8) -- Nothing ---- --
-- >>> parseString "101" :: Maybe (BitArray Int8) -- Just [qq|00000101|] --parseString :: (FiniteBits a) => String -> Maybe (BitArray a) -- | Convert into a list of set bits. -- -- The list is ordered from least significant to most significant bit. toList :: (FiniteBits a) => BitArray a -> [a] -- | Construct from a list of set bits. fromList :: (FiniteBits a) => [a] -> BitArray a -- | Convert into a list of boolean values, which represent the "set" flags -- of each bit. -- -- The list is ordered from least significant to most significant bit. toBoolList :: (FiniteBits a) => BitArray a -> [Bool] -- | Construct from a list of boolean flags for the "set" status of each -- bit. -- -- The list must be ordered from least significant to most significant -- bit. fromBoolList :: (FiniteBits a) => [Bool] -> BitArray a -- | Map over the set bits. map :: (FiniteBits a, FiniteBits b) => (a -> b) -> BitArray a -> BitArray b -- | Perform a right-associative fold over the set bits. foldr :: (FiniteBits a) => (a -> b -> b) -> b -> BitArray a -> b -- | Traverse thru set bits. mapM_ :: (FiniteBits a, Monad m) => (a -> m b) -> BitArray a -> m () -- | Traverse thru set bits. traverse_ :: (FiniteBits a, Applicative f) => (a -> f b) -> BitArray a -> f () instance GHC.Generics.Constructor BitArray.C1_0BitArray instance GHC.Generics.Datatype BitArray.D1BitArray instance Data.Bits.FiniteBits a => Data.Bits.FiniteBits (BitArray.BitArray a) instance Data.Bits.Bits a => Data.Bits.Bits (BitArray.BitArray a) instance GHC.Generics.Generic (BitArray.BitArray a) instance GHC.Arr.Ix a => GHC.Arr.Ix (BitArray.BitArray a) instance GHC.Real.Real a => GHC.Real.Real (BitArray.BitArray a) instance GHC.Classes.Ord a => GHC.Classes.Ord (BitArray.BitArray a) instance GHC.Num.Num a => GHC.Num.Num (BitArray.BitArray a) instance Data.Data.Data a => Data.Data.Data (BitArray.BitArray a) instance GHC.Real.Integral a => GHC.Real.Integral (BitArray.BitArray a) instance GHC.Classes.Eq a => GHC.Classes.Eq (BitArray.BitArray a) instance GHC.Enum.Enum a => GHC.Enum.Enum (BitArray.BitArray a) instance GHC.Enum.Bounded a => GHC.Enum.Bounded (BitArray.BitArray a) instance Data.Bits.FiniteBits a => GHC.Show.Show (BitArray.BitArray a) instance Data.Bits.FiniteBits a => GHC.Read.Read (BitArray.BitArray a) instance Data.Bits.FiniteBits a => Data.String.IsString (BitArray.BitArray a)