data-bword-0.1.0.1: Extra operations on binary words of fixed length

Safe HaskellNone
LanguageHaskell2010

Data.BinaryWord

Description

Extra operations on binary words of fixed length.

Synopsis

Documentation

class (FiniteBits w, FiniteBits (UnsignedWord w), FiniteBits (SignedWord w)) => BinaryWord w where Source #

Two's complement, fixed length binary words.

Associated Types

type UnsignedWord w Source #

The unsigned variant type

type SignedWord w Source #

The signed variant type

Methods

unsignedWord :: w -> UnsignedWord w Source #

Convert the word to the unsigned type (identical to fromIntegral)

signedWord :: w -> SignedWord w Source #

Convert the word to the signed type (identical to fromIntegral)

unwrappedAdd :: w -> w -> (w, UnsignedWord w) Source #

Unwrapped addition

unwrappedMul :: w -> w -> (w, UnsignedWord w) Source #

Unwrapped multiplication

leadingZeroes :: w -> Int Source #

Number of leading (from MSB) zero bits

trailingZeroes :: w -> Int Source #

Number or trailing (from LSB) zero bits

allZeroes :: w Source #

The word with all bits set to 0

allOnes :: w Source #

The word with all bits set to 1

msb :: w Source #

The word with MSB set to 1 and all the other bits set to 0

lsb :: w Source #

The word with LSB set to 1 and all the other bits set to 0

testMsb :: w -> Bool Source #

Test if the MSB is 1

testLsb :: w -> Bool Source #

Test if the LSB is 1

setMsb :: w -> w Source #

Set the MSB to 1

setLsb :: w -> w Source #

Set the LSB to 1

clearMsb :: w -> w Source #

Set the MSB to 0

clearLsb :: w -> w Source #

Set the LSB to 0

Instances

BinaryWord Int8 Source # 
BinaryWord Int16 Source # 
BinaryWord Int32 Source # 
BinaryWord Int64 Source # 
BinaryWord Word8 Source # 
BinaryWord Word16 Source # 
BinaryWord Word32 Source # 
BinaryWord Word64 Source # 

lMsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w Source #

MSB lens.

lLsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w Source #

LSB lens.