-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Extra operations on binary words of fixed length
--   
--   This package provides extra (vs. <a>Data.Bits</a>) operations on
--   binary words of fixed length.
@package data-bword
@version 0.1.0.1


-- | Extra operations on binary words of fixed length.
module Data.BinaryWord

-- | Two's complement, fixed length binary words.
class (FiniteBits w, FiniteBits (UnsignedWord w), FiniteBits (SignedWord w)) => BinaryWord w where type UnsignedWord w type SignedWord w lsb = bit 0 testLsb = flip testBit 0 setLsb = flip setBit 0 clearLsb = flip clearBit 0 where {
    type family UnsignedWord w;
    type family SignedWord w;
}

-- | Convert the word to the unsigned type (identical to
--   <a>fromIntegral</a>)
unsignedWord :: BinaryWord w => w -> UnsignedWord w

-- | Convert the word to the signed type (identical to <a>fromIntegral</a>)
signedWord :: BinaryWord w => w -> SignedWord w

-- | Unwrapped addition
unwrappedAdd :: BinaryWord w => w -> w -> (w, UnsignedWord w)

-- | Unwrapped multiplication
unwrappedMul :: BinaryWord w => w -> w -> (w, UnsignedWord w)

-- | Number of leading (from MSB) zero bits
leadingZeroes :: BinaryWord w => w -> Int

-- | Number or trailing (from LSB) zero bits
trailingZeroes :: BinaryWord w => w -> Int

-- | The word with all bits set to 0
allZeroes :: BinaryWord w => w

-- | The word with all bits set to 1
allOnes :: BinaryWord w => w

-- | The word with MSB set to 1 and all the other bits set to 0
msb :: BinaryWord w => w

-- | The word with LSB set to 1 and all the other bits set to 0
lsb :: BinaryWord w => w

-- | Test if the MSB is 1
testMsb :: BinaryWord w => w -> Bool

-- | Test if the LSB is 1
testLsb :: BinaryWord w => w -> Bool

-- | Set the MSB to 1
setMsb :: BinaryWord w => w -> w

-- | Set the LSB to 1
setLsb :: BinaryWord w => w -> w

-- | Set the MSB to 0
clearMsb :: BinaryWord w => w -> w

-- | Set the LSB to 0
clearLsb :: BinaryWord w => w -> w

-- | MSB lens.
lMsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w

-- | LSB lens.
lLsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w
instance Data.BinaryWord.BinaryWord GHC.Word.Word8
instance Data.BinaryWord.BinaryWord GHC.Word.Word16
instance Data.BinaryWord.BinaryWord GHC.Word.Word32
instance Data.BinaryWord.BinaryWord GHC.Word.Word64
instance Data.BinaryWord.BinaryWord GHC.Int.Int8
instance Data.BinaryWord.BinaryWord GHC.Int.Int16
instance Data.BinaryWord.BinaryWord GHC.Int.Int32
instance Data.BinaryWord.BinaryWord GHC.Int.Int64
