foundation-0.0.8: Alternative prelude with batteries and no dependencies

Safe HaskellNone
LanguageHaskell2010

Foundation.Bits

Synopsis

Documentation

(.<<.) :: Bits a => a -> Int -> a #

Unsafe Shift Left Operator

(.>>.) :: Bits a => a -> Int -> a #

Unsafe Shift Right Operator

class Eq a => Bits a where #

The Bits class defines bitwise operations over integral types.

  • Bits are numbered from 0 with bit 0 being the least significant bit.

Instances

Bits Bool 
Bits Int 

Methods

(.&.) :: Int -> Int -> Int #

(.|.) :: Int -> Int -> Int #

xor :: Int -> Int -> Int #

complement :: Int -> Int #

shift :: Int -> Int -> Int #

rotate :: Int -> Int -> Int #

zeroBits :: Int #

bit :: Int -> Int #

setBit :: Int -> Int -> Int #

clearBit :: Int -> Int -> Int #

complementBit :: Int -> Int -> Int #

testBit :: Int -> Int -> Bool #

bitSizeMaybe :: Int -> Maybe Int #

bitSize :: Int -> Int #

isSigned :: Int -> Bool #

shiftL :: Int -> Int -> Int #

unsafeShiftL :: Int -> Int -> Int #

shiftR :: Int -> Int -> Int #

unsafeShiftR :: Int -> Int -> Int #

rotateL :: Int -> Int -> Int #

rotateR :: Int -> Int -> Int #

popCount :: Int -> Int #

Bits Int8 
Bits Int16 
Bits Int32 
Bits Int64 
Bits Integer 
Bits Word 
Bits Word8 
Bits Word16 
Bits Word32 
Bits Word64 
Bits Natural 
Bits CDev 
Bits CIno 
Bits CMode 
Bits COff 
Bits CPid 
Bits CSsize 
Bits CGid 
Bits CNlink 
Bits CUid 
Bits CTcflag 
Bits CRLim 
Bits Fd 

Methods

(.&.) :: Fd -> Fd -> Fd #

(.|.) :: Fd -> Fd -> Fd #

xor :: Fd -> Fd -> Fd #

complement :: Fd -> Fd #

shift :: Fd -> Int -> Fd #

rotate :: Fd -> Int -> Fd #

zeroBits :: Fd #

bit :: Int -> Fd #

setBit :: Fd -> Int -> Fd #

clearBit :: Fd -> Int -> Fd #

complementBit :: Fd -> Int -> Fd #

testBit :: Fd -> Int -> Bool #

bitSizeMaybe :: Fd -> Maybe Int #

bitSize :: Fd -> Int #

isSigned :: Fd -> Bool #

shiftL :: Fd -> Int -> Fd #

unsafeShiftL :: Fd -> Int -> Fd #

shiftR :: Fd -> Int -> Fd #

unsafeShiftR :: Fd -> Int -> Fd #

rotateL :: Fd -> Int -> Fd #

rotateR :: Fd -> Int -> Fd #

popCount :: Fd -> Int #

Bits WordPtr 
Bits IntPtr 
Bits CChar 
Bits CSChar 
Bits CUChar 
Bits CShort 
Bits CUShort 
Bits CInt 
Bits CUInt 
Bits CLong 
Bits CULong 
Bits CLLong 
Bits CULLong 
Bits CPtrdiff 
Bits CSize 
Bits CWchar 
Bits CSigAtomic 
Bits CIntPtr 
Bits CUIntPtr 
Bits CIntMax 
Bits CUIntMax 
Bits a => Bits (Identity a) 
Bits a => Bits (Const k a b) 

Methods

(.&.) :: Const k a b -> Const k a b -> Const k a b #

(.|.) :: Const k a b -> Const k a b -> Const k a b #

xor :: Const k a b -> Const k a b -> Const k a b #

complement :: Const k a b -> Const k a b #

shift :: Const k a b -> Int -> Const k a b #

rotate :: Const k a b -> Int -> Const k a b #

zeroBits :: Const k a b #

bit :: Int -> Const k a b #

setBit :: Const k a b -> Int -> Const k a b #

clearBit :: Const k a b -> Int -> Const k a b #

complementBit :: Const k a b -> Int -> Const k a b #

testBit :: Const k a b -> Int -> Bool #

bitSizeMaybe :: Const k a b -> Maybe Int #

bitSize :: Const k a b -> Int #

isSigned :: Const k a b -> Bool #

shiftL :: Const k a b -> Int -> Const k a b #

unsafeShiftL :: Const k a b -> Int -> Const k a b #

shiftR :: Const k a b -> Int -> Const k a b #

unsafeShiftR :: Const k a b -> Int -> Const k a b #

rotateL :: Const k a b -> Int -> Const k a b #

rotateR :: Const k a b -> Int -> Const k a b #

popCount :: Const k a b -> Int #

alignRoundUp #

Arguments

:: Int

Number to Align

-> Int

Alignment (power of 2)

-> Int 

Round up (if needed) to a multiple of alignment closst to m

alignment needs to be a power of two

alignRoundUp 16 8 = 16 alignRoundUp 15 8 = 16

alignRoundDown #

Arguments

:: Int

Number to Align

-> Int

Alignment (power of 2)

-> Int 

Round down (if needed) to a multiple of alignment closest to m

alignment needs to be a power of two

alignRoundDown 15 8 = 8
alignRoundDown 8 8  = 8