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

Instances details
BinaryWord Int8 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int8 Source #

type SignedWord Int8 Source #

Methods

unsignedWord :: Int8 -> UnsignedWord Int8 Source #

signedWord :: Int8 -> SignedWord Int8 Source #

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

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

leadingZeroes :: Int8 -> Int Source #

trailingZeroes :: Int8 -> Int Source #

allZeroes :: Int8 Source #

allOnes :: Int8 Source #

msb :: Int8 Source #

lsb :: Int8 Source #

testMsb :: Int8 -> Bool Source #

testLsb :: Int8 -> Bool Source #

setMsb :: Int8 -> Int8 Source #

setLsb :: Int8 -> Int8 Source #

clearMsb :: Int8 -> Int8 Source #

clearLsb :: Int8 -> Int8 Source #

BinaryWord Int16 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int16 Source #

type SignedWord Int16 Source #

Methods

unsignedWord :: Int16 -> UnsignedWord Int16 Source #

signedWord :: Int16 -> SignedWord Int16 Source #

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

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

leadingZeroes :: Int16 -> Int Source #

trailingZeroes :: Int16 -> Int Source #

allZeroes :: Int16 Source #

allOnes :: Int16 Source #

msb :: Int16 Source #

lsb :: Int16 Source #

testMsb :: Int16 -> Bool Source #

testLsb :: Int16 -> Bool Source #

setMsb :: Int16 -> Int16 Source #

setLsb :: Int16 -> Int16 Source #

clearMsb :: Int16 -> Int16 Source #

clearLsb :: Int16 -> Int16 Source #

BinaryWord Int32 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int32 Source #

type SignedWord Int32 Source #

Methods

unsignedWord :: Int32 -> UnsignedWord Int32 Source #

signedWord :: Int32 -> SignedWord Int32 Source #

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

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

leadingZeroes :: Int32 -> Int Source #

trailingZeroes :: Int32 -> Int Source #

allZeroes :: Int32 Source #

allOnes :: Int32 Source #

msb :: Int32 Source #

lsb :: Int32 Source #

testMsb :: Int32 -> Bool Source #

testLsb :: Int32 -> Bool Source #

setMsb :: Int32 -> Int32 Source #

setLsb :: Int32 -> Int32 Source #

clearMsb :: Int32 -> Int32 Source #

clearLsb :: Int32 -> Int32 Source #

BinaryWord Int64 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int64 Source #

type SignedWord Int64 Source #

Methods

unsignedWord :: Int64 -> UnsignedWord Int64 Source #

signedWord :: Int64 -> SignedWord Int64 Source #

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

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

leadingZeroes :: Int64 -> Int Source #

trailingZeroes :: Int64 -> Int Source #

allZeroes :: Int64 Source #

allOnes :: Int64 Source #

msb :: Int64 Source #

lsb :: Int64 Source #

testMsb :: Int64 -> Bool Source #

testLsb :: Int64 -> Bool Source #

setMsb :: Int64 -> Int64 Source #

setLsb :: Int64 -> Int64 Source #

clearMsb :: Int64 -> Int64 Source #

clearLsb :: Int64 -> Int64 Source #

BinaryWord Word8 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word8 Source #

type SignedWord Word8 Source #

Methods

unsignedWord :: Word8 -> UnsignedWord Word8 Source #

signedWord :: Word8 -> SignedWord Word8 Source #

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

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

leadingZeroes :: Word8 -> Int Source #

trailingZeroes :: Word8 -> Int Source #

allZeroes :: Word8 Source #

allOnes :: Word8 Source #

msb :: Word8 Source #

lsb :: Word8 Source #

testMsb :: Word8 -> Bool Source #

testLsb :: Word8 -> Bool Source #

setMsb :: Word8 -> Word8 Source #

setLsb :: Word8 -> Word8 Source #

clearMsb :: Word8 -> Word8 Source #

clearLsb :: Word8 -> Word8 Source #

BinaryWord Word16 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word16 Source #

type SignedWord Word16 Source #

Methods

unsignedWord :: Word16 -> UnsignedWord Word16 Source #

signedWord :: Word16 -> SignedWord Word16 Source #

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

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

leadingZeroes :: Word16 -> Int Source #

trailingZeroes :: Word16 -> Int Source #

allZeroes :: Word16 Source #

allOnes :: Word16 Source #

msb :: Word16 Source #

lsb :: Word16 Source #

testMsb :: Word16 -> Bool Source #

testLsb :: Word16 -> Bool Source #

setMsb :: Word16 -> Word16 Source #

setLsb :: Word16 -> Word16 Source #

clearMsb :: Word16 -> Word16 Source #

clearLsb :: Word16 -> Word16 Source #

BinaryWord Word32 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word32 Source #

type SignedWord Word32 Source #

Methods

unsignedWord :: Word32 -> UnsignedWord Word32 Source #

signedWord :: Word32 -> SignedWord Word32 Source #

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

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

leadingZeroes :: Word32 -> Int Source #

trailingZeroes :: Word32 -> Int Source #

allZeroes :: Word32 Source #

allOnes :: Word32 Source #

msb :: Word32 Source #

lsb :: Word32 Source #

testMsb :: Word32 -> Bool Source #

testLsb :: Word32 -> Bool Source #

setMsb :: Word32 -> Word32 Source #

setLsb :: Word32 -> Word32 Source #

clearMsb :: Word32 -> Word32 Source #

clearLsb :: Word32 -> Word32 Source #

BinaryWord Word64 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word64 Source #

type SignedWord Word64 Source #

Methods

unsignedWord :: Word64 -> UnsignedWord Word64 Source #

signedWord :: Word64 -> SignedWord Word64 Source #

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

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

leadingZeroes :: Word64 -> Int Source #

trailingZeroes :: Word64 -> Int Source #

allZeroes :: Word64 Source #

allOnes :: Word64 Source #

msb :: Word64 Source #

lsb :: Word64 Source #

testMsb :: Word64 -> Bool Source #

testLsb :: Word64 -> Bool Source #

setMsb :: Word64 -> Word64 Source #

setLsb :: Word64 -> Word64 Source #

clearMsb :: Word64 -> Word64 Source #

clearLsb :: Word64 -> 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.