bit-vector-0.1.0: Simple bit vectors for Haskell







Bit vectors

type BitVector = Vector BoolSource

A BitVector is a little-endian Vector of Bools.


To and from other Bits instances

unpack :: Bits a => a -> BitVectorSource

Converts an instance of Bits to a BitVector.

Note: this uses bitSize, and will not work for instances which do not implement this method, notably Integer. To unpack Integer values, use unpackInteger.

pack :: Bits a => BitVector -> aSource

Converts a BitVector to an instance of Bits.

Specialized conversions


pad :: Int -> BitVector -> BitVectorSource

Pads a BitVector to the specified length by adding a vector of False values to the most-significant end.

padMax :: BitVector -> BitVector -> (BitVector, BitVector)Source

Pads two BitVectors to the length of the longest vector. If the vectors are the same length, padMax does nothing.

zipPad :: BitVector -> BitVector -> Vector (Bool, Bool)Source

Like zip, except pads the vectors to equal length rather than discarding elements of the longer vector.

trimLeading :: BitVector -> BitVectorSource

Discards any False values at the most-significant end of the given BitVector.