bits-0.5.1: Various bit twiddling and bitwise serialization primitives

Copyright(c) Edward Kmett 2013
LicenseBSD3
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell98

Data.Bits.Coding

Contents

Description

 

Synopsis

Documentation

newtype Coding m a Source #

Constructors

Coding 

Fields

Instances

MonadTrans Coding Source # 

Methods

lift :: Monad m => m a -> Coding m a #

MonadReader e m => MonadReader e (Coding m) Source # 

Methods

ask :: Coding m e #

local :: (e -> e) -> Coding m a -> Coding m a #

reader :: (e -> a) -> Coding m a #

MonadState s m => MonadState s (Coding m) Source # 

Methods

get :: Coding m s #

put :: s -> Coding m () #

state :: (s -> (a, s)) -> Coding m a #

Monad m => Monad (Coding m) Source # 

Methods

(>>=) :: Coding m a -> (a -> Coding m b) -> Coding m b #

(>>) :: Coding m a -> Coding m b -> Coding m b #

return :: a -> Coding m a #

fail :: String -> Coding m a #

Functor (Coding m) Source # 

Methods

fmap :: (a -> b) -> Coding m a -> Coding m b #

(<$) :: a -> Coding m b -> Coding m a #

Monad m => Applicative (Coding m) Source # 

Methods

pure :: a -> Coding m a #

(<*>) :: Coding m (a -> b) -> Coding m a -> Coding m b #

(*>) :: Coding m a -> Coding m b -> Coding m b #

(<*) :: Coding m a -> Coding m b -> Coding m a #

(Monad m, Alternative m) => Alternative (Coding m) Source # 

Methods

empty :: Coding m a #

(<|>) :: Coding m a -> Coding m a -> Coding m a #

some :: Coding m a -> Coding m [a] #

many :: Coding m a -> Coding m [a] #

MonadPlus m => MonadPlus (Coding m) Source # 

Methods

mzero :: Coding m a #

mplus :: Coding m a -> Coding m a -> Coding m a #

MonadGet m => MonadGet (Coding m) Source # 
MonadPut m => MonadPut (Coding m) Source # 
type Bytes (Coding m) Source # 
type Bytes (Coding m) = Bytes m
type Remaining (Coding m) Source # 

Get

getAligned :: MonadGet m => m a -> Coding m a Source #

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 Bool Source #

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

getBits :: (MonadGet m, Bits b) => Int -> Int -> b -> Coding m b Source #

getBitsFrom :: (MonadGet m, Bits b) => Int -> b -> Coding m b Source #

Put

putAligned :: MonadPut m => m a -> Coding m a Source #

Emit any remaining contents from the bit buffer.

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

putUnaligned :: (MonadPut m, FiniteBits b) => b -> Coding m () Source #

Put all the bits without a flush

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

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

putBits :: (MonadPut m, Bits b) => Int -> Int -> b -> Coding m () Source #

Put a (closed) range of bits

putBitsFrom :: (MonadPut m, Bits b) => Int -> b -> Coding m () Source #

putBitsFrom from b = putBits from 0 b