-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Various bit twiddling and bitwise serialization primitives
--
-- Various bit twiddling and bitwise serialization primitives
@package bits
@version 0.3.3
-- | Calculate a number of fiddly bit operations using fast de Bruijn
-- multiplication tables.
module Data.Bits.Extras
class (Num t, Bits t) => Ranked t where lsb n = rank n - 1 rank 0 = 0 rank n = lsb n + 1
lsb :: Ranked t => t -> Int
rank :: Ranked t => t -> Int
nlz :: Ranked t => t -> Int
log2 :: Word32 -> Int
w8 :: Integral a => a -> Word8
w16 :: Integral a => a -> Word16
w32 :: Integral a => a -> Word32
w64 :: Integral a => a -> Word64
instance Ranked Int8
instance Ranked Int16
instance Ranked Int32
instance Ranked Int64
instance Ranked Word8
instance Ranked Word16
instance Ranked Word32
instance Ranked Word64
module Data.Bits.Coding
newtype Coding m a
Coding :: (forall r. (a -> Int -> Word8 -> m r) -> Int -> Word8 -> m r) -> Coding m a
runCoding :: Coding m a -> forall r. (a -> Int -> Word8 -> m r) -> Int -> Word8 -> m r
-- | Get something from byte-aligned storage, starting on the next
-- byte and discarding any left over bits in the buffer.
--
-- NB: Using any operation from MonadGet other than
-- checking remaining or isEmpty will implicitly perform
-- this operation.
getAligned :: MonadGet m => m a -> Coding m a
-- | Get a single bit, consuming an entire byte if the
-- bit buffer is empty
getBit :: MonadGet m => Coding m Bool
-- | Emit any remaining contents from the bit buffer.
--
-- Any use of the combinators from MonadPut (including
-- flush) will cause this to happen.
putAligned :: MonadPut m => m a -> Coding m a
-- | Put a single bit, emitting an entire byte if the bit
-- buffer is full
putBit :: MonadPut m => Bool -> Coding m ()
instance MonadPut m => MonadPut (Coding m)
instance MonadGet m => MonadGet (Coding m)
instance MonadReader e m => MonadReader e (Coding m)
instance MonadState s m => MonadState s (Coding m)
instance MonadTrans Coding
instance MonadPlus m => MonadPlus (Coding m)
instance (Monad m, Alternative m) => Alternative (Coding m)
instance Monad m => Monad (Coding m)
instance Monad m => Applicative (Coding m)
instance Functor (Coding m)