data-bword-0.1.0.2: Extra operations on binary words of fixed length
Safe HaskellSafe-Inferred
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 Int16 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int16 Source #

type SignedWord Int16 Source #

BinaryWord Int32 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int32 Source #

type SignedWord Int32 Source #

BinaryWord Int64 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int64 Source #

type SignedWord Int64 Source #

BinaryWord Int8 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Int8 Source #

type SignedWord Int8 Source #

BinaryWord Word16 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word16 Source #

type SignedWord Word16 Source #

BinaryWord Word32 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word32 Source #

type SignedWord Word32 Source #

BinaryWord Word64 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word64 Source #

type SignedWord Word64 Source #

BinaryWord Word8 Source # 
Instance details

Defined in Data.BinaryWord

Associated Types

type UnsignedWord Word8 Source #

type SignedWord Word8 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.