bits-0.3: Various bit twiddling and bitwise serialization primitives

Portabilitynon-portable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Inferred

Data.Bits.Coding

Contents

Description

 

Synopsis

Documentation

newtype Coding m a Source

Constructors

Coding 

Fields

runCoding :: forall r. (a -> Int -> Word8 -> m r) -> Int -> Word8 -> m r
 

Get

getAligned :: MonadGet m => m a -> Coding m aSource

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.

getBit :: MonadGet m => Coding m BoolSource

Get a single bit, consuming an entire byte if the bit buffer is empty

Put

putAligned :: MonadPut m => m a -> Coding m aSource

Emit any remaining contents from the bit buffer.

Any use of the combinators from MonadPut (including flush) will cause this to happen.

putBit :: MonadPut m => Bool -> Coding m ()Source

Put a single bit, emitting an entire byte if the bit buffer is full