bitwise-0.1.0.2: fast multi-dimensional unboxed bit packed Bool arrays

Copyright(c) Claude Heiland-Allen 2012
LicenseBSD3
Maintainerclaude@mathr.co.uk
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Bits.Bitwise

Contents

Description

Lifting boolean operations on Bool to bitwise operations on Bits.

Packing bits into words, and unpacking words into bits.

Synopsis

Boolean operations lifted to bitwise operations.

repeat :: (Num b, Bits b) => Bool -> b Source

Lift a boolean constant to a bitwise constant.

map Source

Arguments

:: (Num b, Bits b) 
=> (Bool -> Bool)

operation

-> b 
-> b 

Lift a unary boolean operation to a bitwise operation.

The implementation is by exhaustive input/output case analysis: thus the operation provided must be total.

zipWith Source

Arguments

:: (Num b, Bits b) 
=> (Bool -> Bool -> Bool)

operation

-> b 
-> b 
-> b 

Lift a binary boolean operation to a bitwise operation.

The implementation is by exhaustive input/output case analysis: thus the operation provided must be total.

or :: (Num b, Bits b) => b -> Bool Source

True when any bit is set.

and :: (Num b, Bits b) => b -> Bool Source

True when all bits are set.

any Source

Arguments

:: (Num b, Bits b) 
=> (Bool -> Bool)

predicate

-> b 
-> Bool 

True when the predicate is true for any bit.

all Source

Arguments

:: (Num b, Bits b) 
=> (Bool -> Bool)

predicate

-> b 
-> Bool 

True when the predicate is true for all bits.

isUniform :: (Num b, Bits b) => b -> Maybe Bool Source

Determine if a Bits is all 1s, all 0s, or neither.

Splitting/joining Bits to/from (lsb, msb).

mask Source

Arguments

:: (Num b, Bits b) 
=> Int

count

-> b 

A mask with count least significant bits set.

splitAt Source

Arguments

:: (Num b, Bits b) 
=> Int

split point

-> b

word

-> (b, b)

(lsb, msb)

Split a word into (lsb, msb). Ensures lsb has no set bits above the split point.

joinAt Source

Arguments

:: (Num b, Bits b) 
=> Int

join point

-> b

least significant bits

-> b

most significant bits

-> b

word

Join lsb with msb to make a word. Assumes lsb has no set bits above the join point.

fromBool :: (Num b, Bits b) => Bool -> b Source

The least significant bit.

(Un)packing Bits to/from lists of Bool.

fromListLE Source

Arguments

:: (Num b, Bits b) 
=> [Bool]

[least significant bit, ..., most significant bit]

-> b 

Convert a little-endian list of bits to Bits.

toListLE Source

Arguments

:: (Num b, Bits b) 
=> b 
-> [Bool]

[least significant bit, ..., most significant bit]

Convert a Bits (with a defined bitSize) to a list of bits, in little-endian order.

fromListBE Source

Arguments

:: (Num b, Bits b) 
=> [Bool]

[most significant bit, ..., least significant bit]

-> b 

Convert a big-endian list of bits to Bits.

toListBE Source

Arguments

:: (Num b, Bits b) 
=> b 
-> [Bool]

[most significant bit, ..., least significant bit]

Convert a Bits (with a defined bitSize) to a list of bits, in big-endian order.

(Un)packing Word8 to/from 8-tuples of Bool.

packWord8LE Source

Arguments

:: Bool

least significant bit

-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool

most significant bit

-> Word8 

Pack bits into a byte in little-endian order.

unpackWord8LE Source

Arguments

:: Word8 
-> (Bool, Bool, Bool, Bool, Bool, Bool, Bool, Bool)

(least significant bit, ..., most significant bit)

Extract the bits from a byte in little-endian order.

packWord8BE Source

Arguments

:: Bool

most significant bit

-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool 
-> Bool

least significant bit

-> Word8 

Pack bits into a byte in big-endian order.

unpackWord8BE Source

Arguments

:: Word8 
-> (Bool, Bool, Bool, Bool, Bool, Bool, Bool, Bool)

(most significant bit, ..., least significant bit)

Extract the bits from a byte in big-endian order.