basement-0.0.15: Foundation scrap box of array & string
License BSD-style
Maintainer Haskell Foundation
Stability experimental
Portability portable
Safe Haskell None
Language Haskell2010

Basement.Bits

Description

Synopsis

Documentation

class BitOps bits where Source #

operation over bits

Minimal complete definition

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

Methods

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

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

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

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

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

bit :: Offset Bool -> bits Source #

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

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

test the bit at the given index is set

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

set the bit at the given index

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

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

clear the bit at the given index

Instances

Instances details
BitOps Bool Source #
Instance details

Defined in Basement.Bits

BitOps Int8 Source #
Instance details

Defined in Basement.Bits

BitOps Int16 Source #
Instance details

Defined in Basement.Bits

BitOps Int32 Source #
Instance details

Defined in Basement.Bits

BitOps Int64 Source #
Instance details

Defined in Basement.Bits

BitOps Word Source #
Instance details

Defined in Basement.Bits

BitOps Word8 Source #
Instance details

Defined in Basement.Bits

BitOps Word16 Source #
Instance details

Defined in Basement.Bits

BitOps Word32 Source #
Instance details

Defined in Basement.Bits

BitOps Word64 Source #
Instance details

Defined in Basement.Bits

BitOps Word128 Source #
Instance details

Defined in Basement.Bits

BitOps Word256 Source #
Instance details

Defined in Basement.Bits

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

Defined in Basement.Bits

class FiniteBitsOps bits where Source #

operation over finite bits

Methods

numberOfBits :: bits -> CountOf Bool Source #

get the number of bits in the given object

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

rotate the given bit set.

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

rotate the given bit set.

popCount :: bits -> CountOf Bool Source #

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

bitFlip :: bits -> bits Source #

reverse all bits in the argument

countLeadingZeros :: bits -> CountOf Bool Source #

count of the number of leading zeros

countTrailingZeros :: bits -> CountOf Bool Source #

count of the number of trailing zeros

Instances

Instances details
FiniteBitsOps Bool Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Int8 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Int16 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Int32 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Int64 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word8 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word16 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word32 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word64 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word128 Source #
Instance details

Defined in Basement.Bits

FiniteBitsOps Word256 Source #
Instance details

Defined in Basement.Bits

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

Defined in Basement.Bits

data Bits (n :: Nat ) Source #

Bool set of n bits.

Instances

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

Defined in Basement.Bits

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

Defined in Basement.Bits

Eq ( Bits n) Source #
Instance details

Defined in Basement.Bits

Ord ( Bits n) Source #
Instance details

Defined in Basement.Bits

Show ( Bits n) Source #
Instance details

Defined in Basement.Bits

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

Defined in Basement.Bits

Associated Types

type Difference ( Bits n) Source #

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

Defined in Basement.Bits

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

Defined in Basement.Bits

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

Defined in Basement.Bits

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

Defined in Basement.Bits

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

Defined in Basement.Bits

type Difference ( Bits n) Source #
Instance details

Defined in Basement.Bits

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

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 Source #

construct a Bits with all bits set.

this function is equivalet to maxBound