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 #

Two's complement, fixed length binary words.

Associated Types

type UnsignedWord w #

The unsigned variant type

type SignedWord w #

The signed variant type

Methods

unsignedWord :: w -> UnsignedWord w #

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

signedWord :: w -> SignedWord w #

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

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

Unwrapped addition

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

Unwrapped multiplication

leadingZeroes :: w -> Int #

Number of leading (from MSB) zero bits

trailingZeroes :: w -> Int #

Number or trailing (from LSB) zero bits

allZeroes :: w #

The word with all bits set to 0

allOnes :: w #

The word with all bits set to 1

msb :: w #

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

lsb :: w #

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

testMsb :: w -> Bool #

Test if the MSB is 1

testLsb :: w -> Bool #

Test if the LSB is 1

setMsb :: w -> w #

Set the MSB to 1

setLsb :: w -> w #

Set the LSB to 1

clearMsb :: w -> w #

Set the MSB to 0

clearLsb :: w -> w #

Set the LSB to 0

Instances

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

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

MSB lens.

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

LSB lens.