basement-0.0.12: Foundation scrap box of array & string
LicenseBSD-style
MaintainerHaskell Foundation
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Basement.Bits

Description

 
Synopsis

Documentation

class BitOps bits where #

operation over bits

Minimal complete definition

(.&.), (.|.), (.^.), (.<<.), (.>>.)

Methods

(.&.) :: bits -> bits -> bits infixl 7 #

(.|.) :: bits -> bits -> bits infixl 5 #

(.^.) :: bits -> bits -> bits infixl 6 #

(.<<.) :: bits -> CountOf Bool -> bits infixl 8 #

(.>>.) :: bits -> CountOf Bool -> bits infixl 8 #

bit :: Offset Bool -> bits #

construct a bit set with the bit at the given index set.

default bit :: Integral bits => Offset Bool -> bits #

isBitSet :: bits -> Offset Bool -> Bool #

test the bit at the given index is set

default isBitSet :: (Integral bits, Eq bits) => bits -> Offset Bool -> Bool #

setBit :: bits -> Offset Bool -> bits #

set the bit at the given index

default setBit :: Integral bits => bits -> Offset Bool -> bits #

clearBit :: bits -> Offset Bool -> bits #

clear the bit at the given index

default clearBit :: FiniteBitsOps bits => bits -> Offset Bool -> bits #

Instances

Instances details
BitOps Bool # 
Instance details

Defined in Basement.Bits

BitOps Int8 # 
Instance details

Defined in Basement.Bits

BitOps Int16 # 
Instance details

Defined in Basement.Bits

BitOps Int32 # 
Instance details

Defined in Basement.Bits

BitOps Int64 # 
Instance details

Defined in Basement.Bits

BitOps Word # 
Instance details

Defined in Basement.Bits

BitOps Word8 # 
Instance details

Defined in Basement.Bits

BitOps Word16 # 
Instance details

Defined in Basement.Bits

BitOps Word32 # 
Instance details

Defined in Basement.Bits

BitOps Word64 # 
Instance details

Defined in Basement.Bits

BitOps Word128 # 
Instance details

Defined in Basement.Bits

BitOps Word256 # 
Instance details

Defined in Basement.Bits

SizeValid n => BitOps (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

(.&.) :: Bits n -> Bits n -> Bits n #

(.|.) :: Bits n -> Bits n -> Bits n #

(.^.) :: Bits n -> Bits n -> Bits n #

(.<<.) :: Bits n -> CountOf Bool -> Bits n #

(.>>.) :: Bits n -> CountOf Bool -> Bits n #

bit :: Offset Bool -> Bits n #

isBitSet :: Bits n -> Offset Bool -> Bool #

setBit :: Bits n -> Offset Bool -> Bits n #

clearBit :: Bits n -> Offset Bool -> Bits n #

class FiniteBitsOps bits where #

operation over finite bits

Minimal complete definition

numberOfBits, rotateL, rotateR, popCount, bitFlip

Methods

numberOfBits :: bits -> CountOf Bool #

get the number of bits in the given object

rotateL :: bits -> CountOf Bool -> bits infixl 8 #

rotate the given bit set.

rotateR :: bits -> CountOf Bool -> bits infixl 8 #

rotate the given bit set.

popCount :: bits -> CountOf Bool #

count of number of bit set to 1 in the given bit set.

bitFlip :: bits -> bits #

reverse all bits in the argument

countLeadingZeros :: bits -> CountOf Bool #

count of the number of leading zeros

default countLeadingZeros :: BitOps bits => bits -> CountOf Bool #

countTrailingZeros :: bits -> CountOf Bool #

count of the number of trailing zeros

default countTrailingZeros :: BitOps bits => bits -> CountOf Bool #

Instances

Instances details
FiniteBitsOps Bool # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Int8 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Int16 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Int32 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Int64 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word8 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word16 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word32 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word64 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word128 # 
Instance details

Defined in Basement.Bits

FiniteBitsOps Word256 # 
Instance details

Defined in Basement.Bits

(SizeValid n, NatWithinBound (CountOf Bool) n) => FiniteBitsOps (Bits n) # 
Instance details

Defined in Basement.Bits

data Bits (n :: Nat) #

Bool set of n bits.

Instances

Instances details
SizeValid n => Bounded (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

minBound :: Bits n #

maxBound :: Bits n #

SizeValid n => Enum (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

succ :: Bits n -> Bits n #

pred :: Bits n -> Bits n #

toEnum :: Int -> Bits n #

fromEnum :: Bits n -> Int #

enumFrom :: Bits n -> [Bits n] #

enumFromThen :: Bits n -> Bits n -> [Bits n] #

enumFromTo :: Bits n -> Bits n -> [Bits n] #

enumFromThenTo :: Bits n -> Bits n -> Bits n -> [Bits n] #

Eq (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

(==) :: Bits n -> Bits n -> Bool #

(/=) :: Bits n -> Bits n -> Bool #

Ord (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

compare :: Bits n -> Bits n -> Ordering #

(<) :: Bits n -> Bits n -> Bool #

(<=) :: Bits n -> Bits n -> Bool #

(>) :: Bits n -> Bits n -> Bool #

(>=) :: Bits n -> Bits n -> Bool #

max :: Bits n -> Bits n -> Bits n #

min :: Bits n -> Bits n -> Bits n #

Show (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

showsPrec :: Int -> Bits n -> ShowS #

show :: Bits n -> String #

showList :: [Bits n] -> ShowS #

SizeValid n => Subtractive (Bits n) # 
Instance details

Defined in Basement.Bits

Associated Types

type Difference (Bits n) #

Methods

(-) :: Bits n -> Bits n -> Difference (Bits n) #

SizeValid n => Additive (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

azero :: Bits n #

(+) :: Bits n -> Bits n -> Bits n #

scale :: IsNatural n0 => n0 -> Bits n -> Bits n #

SizeValid n => IDivisible (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

div :: Bits n -> Bits n -> Bits n #

mod :: Bits n -> Bits n -> Bits n #

divMod :: Bits n -> Bits n -> (Bits n, Bits n) #

SizeValid n => Multiplicative (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

midentity :: Bits n #

(*) :: Bits n -> Bits n -> Bits n #

(^) :: (IsNatural n0, Enum n0, IDivisible n0) => Bits n -> n0 -> Bits n #

SizeValid n => BitOps (Bits n) # 
Instance details

Defined in Basement.Bits

Methods

(.&.) :: Bits n -> Bits n -> Bits n #

(.|.) :: Bits n -> Bits n -> Bits n #

(.^.) :: Bits n -> Bits n -> Bits n #

(.<<.) :: Bits n -> CountOf Bool -> Bits n #

(.>>.) :: Bits n -> CountOf Bool -> Bits n #

bit :: Offset Bool -> Bits n #

isBitSet :: Bits n -> Offset Bool -> Bool #

setBit :: Bits n -> Offset Bool -> Bits n #

clearBit :: Bits n -> Offset Bool -> Bits n #

(SizeValid n, NatWithinBound (CountOf Bool) n) => FiniteBitsOps (Bits n) # 
Instance details

Defined in Basement.Bits

type Difference (Bits n) # 
Instance details

Defined in Basement.Bits

type Difference (Bits n) = Bits n

toBits :: SizeValid n => Natural -> Bits n #

convert the given Natural into a Bits of size n

if bits that are not within the boundaries of the 'Bits n' will be truncated.

allOne :: forall n. SizeValid n => Bits n #

construct a Bits with all bits set.

this function is equivalet to maxBound