bit-vector-0.2.0: Simple bit vectors for Haskell

Copyright(c) Adam C. Foltzer 2011-2015
LicenseBSD3
Maintaineracfoltzer@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.Vector.Bit

Contents

Description

 

Synopsis

Bit vectors

type BitVector = Vector Bool Source

A BitVector is a little-endian Vector of Bools.

Conversions

To and from other Bits instances

unpack :: FiniteBits a => a -> BitVector Source

Converts an instance of FiniteBits to a BitVector.

pack :: (Num a, Bits a) => BitVector -> a Source

Converts a BitVector to an instance of Bits.

Specialized conversions

Utilities

pad :: Int -> BitVector -> BitVector Source

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 -> BitVector Source

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

(==~) :: BitVector -> BitVector -> Bool infix 4 Source

Equality modulo trailing False bits