-- 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. Data.Bits) operations on -- binary words of fixed length. @package data-bword @version 0.1 -- | Extra operations on binary words of fixed length. module Data.BinaryWord -- | Two's complement, fixed length binary words. class (Bits w, Bits (UnsignedWord w), Bits (SignedWord w)) => BinaryWord w where type family UnsignedWord w type family SignedWord w lsb = bit 0 testLsb = flip testBit 0 setLsb = flip setBit 0 clearLsb = flip clearBit 0 unsignedWord :: BinaryWord w => w -> UnsignedWord w signedWord :: BinaryWord w => w -> SignedWord w unwrappedAdd :: BinaryWord w => w -> w -> (w, UnsignedWord w) unwrappedMul :: BinaryWord w => w -> w -> (w, UnsignedWord w) leadingZeroes :: BinaryWord w => w -> Int trailingZeroes :: BinaryWord w => w -> Int allZeroes :: BinaryWord w => w allOnes :: BinaryWord w => w msb :: BinaryWord w => w lsb :: BinaryWord w => w testMsb :: BinaryWord w => w -> Bool testLsb :: BinaryWord w => w -> Bool setMsb :: BinaryWord w => w -> w setLsb :: BinaryWord w => w -> w clearMsb :: BinaryWord w => w -> w 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 BinaryWord Int64 instance BinaryWord Int32 instance BinaryWord Int16 instance BinaryWord Int8 instance BinaryWord Word64 instance BinaryWord Word32 instance BinaryWord Word16 instance BinaryWord Word8