bits-0.5.3: Various bit twiddling and bitwise serialization primitives
Copyright(c) Edward Kmett 2013
LicenseBSD3
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Bits.Coding

Contents

Description

 
Synopsis

Documentation

newtype Coding m a Source #

Constructors

Coding 

Fields

Instances

Instances details
MonadTrans Coding Source # 
Instance details

Defined in Data.Bits.Coding

Methods

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

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

Defined in Data.Bits.Coding

Methods

get :: Coding m s #

put :: s -> Coding m () #

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

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

Defined in Data.Bits.Coding

Methods

ask :: Coding m e #

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

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

Monad m => Monad (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

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 #

Functor (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

Methods

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

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

MonadFail m => MonadFail (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

Methods

fail :: String -> Coding m a #

Monad m => Applicative (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

Methods

pure :: a -> Coding m a #

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

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

(*>) :: 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 # 
Instance details

Defined in Data.Bits.Coding

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 # 
Instance details

Defined in Data.Bits.Coding

Methods

mzero :: Coding m a #

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

MonadPut m => MonadPut (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

MonadGet m => MonadGet (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

Associated Types

type Remaining (Coding m) #

type Bytes (Coding m) #

type Bytes (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

type Bytes (Coding m) = Bytes m
type Remaining (Coding m) Source # 
Instance details

Defined in Data.Bits.Coding

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