haskus-system-0.6.0.0: Haskus system programming framework

Safe HaskellNone
LanguageHaskell2010

Haskus.Format.Binary.Bits.Put

Contents

Description

Bit putter

Synopsis

Documentation

data BitPutState Source #

BitPut state

Constructors

BitPutState 

Fields

newBitPutState :: BitOrder -> BitPutState Source #

Create a new BitPut state

putBitsBuffer :: Buffer -> BitPutState -> BitPutState Source #

Put a Buffer

Examples: 3 bits are already written in the current byte BB: ABCDEFGH IJKLMNOP -> xxxABCDE FGHIJKLM NOPxxxxx LL: ABCDEFGH IJKLMNOP -> LMNOPxxx DEFGHIJK xxxxxABC BL: ABCDEFGH IJKLMNOP -> xxxPONML KJIHGFED CBAxxxxx LB: ABCDEFGH IJKLMNOP -> EDCBAxxx MLKJIHGF xxxxxPON

getBitPutBufferList :: BitPutState -> BufferList Source #

Get a lazy byte string

Monadic

type BitPut a = BitPutT Identity a Source #

BitPut monad

type BitPutT m a = StateT BitPutState m a Source #

BitPut monad transformer

runBitPut :: BitOrder -> BitPut a -> Buffer Source #

Evaluate a BitPut monad

runBitPutT :: Monad m => BitOrder -> BitPutT m a -> m Buffer Source #

Evaluate a BitPut monad

putBitsM :: (Monad m, Integral a, FiniteBits a, BitReversable a) => Word -> a -> BitPutT m () Source #

Put bits (monadic)

putBitBoolM :: Monad m => Bool -> BitPutT m () Source #

Put a single bit (monadic)

putBitsBufferM :: Monad m => Buffer -> BitPutT m () Source #

Put a Buffer (monadic)

changeBitPutOrder :: Monad m => BitOrder -> BitPutT m () Source #

Change the current bit ordering

Be careful to change the outer bit ordering (B* to L* or the inverse) only on bytes boundaries! Otherwise, you will write the same bits more than once.

withBitPutOrder :: Monad m => BitOrder -> BitPutT m a -> BitPutT m a Source #

Change the bit ordering for the wrapped BitPut

Be careful, this function uses changeBitPutOrder internally.