-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bit manipulation -- -- Please see README.md @package hw-bits @version 0.7.2.0 module HaskellWorks.Data.Bits.BitLength class BitLength v -- | Number of bits in a value including ones and zeros. bitLength :: BitLength v => v -> Count -- | Number of bits in a value including ones and zeros as a position. endPosition :: BitLength v => v -> Position elemBitLength :: (AtIndex v, BitLength (Elem v)) => v -> Count elemBitEnd :: (AtIndex v, BitLength (Elem v)) => v -> Position instance HaskellWorks.Data.Bits.BitLength.BitLength GHC.Types.Bool instance HaskellWorks.Data.Bits.BitLength.BitLength [GHC.Types.Bool] instance HaskellWorks.Data.Bits.BitLength.BitLength GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitLength.BitLength GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitLength.BitLength GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitLength.BitLength GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitLength.BitLength (HaskellWorks.Data.Naive.Naive GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitLength.BitLength (HaskellWorks.Data.Naive.Naive GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitLength.BitLength (HaskellWorks.Data.Naive.Naive GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitLength.BitLength (HaskellWorks.Data.Naive.Naive GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitLength.BitLength [GHC.Word.Word8] instance HaskellWorks.Data.Bits.BitLength.BitLength [GHC.Word.Word16] instance HaskellWorks.Data.Bits.BitLength.BitLength [GHC.Word.Word32] instance HaskellWorks.Data.Bits.BitLength.BitLength [GHC.Word.Word64] instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.BitLength.BitLength (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.BitWise -- | Class of values that have bit wise logical operations class BitWise a -- | Bit-wise AND (.&.) :: BitWise a => a -> a -> a -- | Bit-wise OR (.|.) :: BitWise a => a -> a -> a -- | Bit-wise XOR (.^.) :: BitWise a => a -> a -> a -- | Bit-wise complement comp :: BitWise a => a -> a -- | Bit-wise value of the given type with all bits set to zero all0s :: BitWise a => a -- | Bit-wise value of the given type with all bits set to one all1s :: BitWise a => a infixl 7 .&. infixl 5 .|. infixl 6 .^. class Bit a bit :: Bit a => Position -> a -- | Class of values that have shift operations class Shift a -- | Shift left by the specified count (.<.) :: Shift a => a -> Count -> a -- | Shift right by the specified count (.>.) :: Shift a => a -> Count -> a infixl 8 .<. infixl 8 .>. class TestBit a -- | Test whether the bit ad the given offset is set (.?.) :: TestBit a => a -> Position -> Bool infixl 9 .?. instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Types.Bool instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Types.Int instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitWise.Bit GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitWise.Bit (HaskellWorks.Data.Naive.Naive GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitWise.Bit (HaskellWorks.Data.Naive.Naive GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitWise.Bit (HaskellWorks.Data.Naive.Naive GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitWise.Bit (HaskellWorks.Data.Naive.Naive GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitWise.BitWise GHC.Types.Int instance HaskellWorks.Data.Bits.BitWise.BitWise GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitWise.BitWise GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitWise.BitWise GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitWise.BitWise GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Types.Bool instance HaskellWorks.Data.Bits.BitWise.TestBit [GHC.Types.Bool] instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Types.Int instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitWise.TestBit GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitWise.TestBit (HaskellWorks.Data.Naive.Naive GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitWise.TestBit (HaskellWorks.Data.Naive.Naive GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitWise.TestBit (HaskellWorks.Data.Naive.Naive GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitWise.TestBit (HaskellWorks.Data.Naive.Naive GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.BitWise.TestBit (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Types.Int instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Int.Int8 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Int.Int16 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Int.Int32 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Int.Int64 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitWise.Shift GHC.Word.Word64 module HaskellWorks.Data.Bits.BitParse -- | Parsers for bit strings class BitParse a -- | Version of bit string parser that can consume no inputs bitParse0 :: BitParse a => Parser a -- | Version of bit string parser that must consume at least one input bitParse1 :: BitParse a => Parser a instance HaskellWorks.Data.Bits.BitParse.BitParse GHC.Types.Bool instance HaskellWorks.Data.Bits.BitParse.BitParse GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitParse.BitParse GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitParse.BitParse GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitParse.BitParse GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitParse.BitParse Data.ByteString.Internal.ByteString instance HaskellWorks.Data.Bits.BitParse.BitParse [GHC.Word.Word8] instance HaskellWorks.Data.Bits.BitParse.BitParse [GHC.Word.Word16] instance HaskellWorks.Data.Bits.BitParse.BitParse [GHC.Word.Word32] instance HaskellWorks.Data.Bits.BitParse.BitParse [GHC.Word.Word64] instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.BitParse.BitParse (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.BitRead -- | Bit string reader that produces a value of a type class BitRead a -- | Read a bit string into a value bitRead :: BitRead a => String -> Maybe a instance HaskellWorks.Data.Bits.BitRead.BitRead GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitRead.BitRead GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitRead.BitRead GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitRead.BitRead GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitRead.BitRead Data.ByteString.Internal.ByteString instance HaskellWorks.Data.Bits.BitRead.BitRead [GHC.Word.Word8] instance HaskellWorks.Data.Bits.BitRead.BitRead [GHC.Word.Word16] instance HaskellWorks.Data.Bits.BitRead.BitRead [GHC.Word.Word32] instance HaskellWorks.Data.Bits.BitRead.BitRead [GHC.Word.Word64] instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.BitRead.BitRead (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) instance HaskellWorks.Data.Bits.BitRead.BitRead [GHC.Types.Bool] module HaskellWorks.Data.Bits.Broadword.Type newtype Broadword a Broadword :: a -> Broadword a broadword :: Broadword Word64 -> Word64 instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (HaskellWorks.Data.Bits.Broadword.Type.Broadword a) instance GHC.Generics.Generic (HaskellWorks.Data.Bits.Broadword.Type.Broadword a) instance GHC.Base.Functor HaskellWorks.Data.Bits.Broadword.Type.Broadword instance GHC.Show.Show a => GHC.Show.Show (HaskellWorks.Data.Bits.Broadword.Type.Broadword a) instance GHC.Classes.Eq a => GHC.Classes.Eq (HaskellWorks.Data.Bits.Broadword.Type.Broadword a) module HaskellWorks.Data.Bits.Broadword.Word16 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16 } -- such that the highest bit is set to 1 and all other bits are cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (h 2) "" -- "aaaa" -- -- >>> showHex (h 4) "" -- "8888" -- -- >>> showHex (h 8) "" -- "8080" -- -- >>> showHex (h 16) "" -- "8000" --h :: Int -> Word16 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16 } -- such that the lowest bit is set to 1 and all other bits are cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (l 2) "" -- "5555" -- -- >>> showHex (l 4) "" -- "1111" -- -- >>> showHex (l 8) "" -- "101" -- -- >>> showHex (l 16) "" -- "1" --l :: Int -> Word16 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16 }. -- -- The subtraction respects 2's complement so sub-words may be regarded -- as signed or unsigned words. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x0201 0x0101) "" -- "100" -- -- >>> showHex (kBitDiff 8 0x0201 0x0102) "" -- "1ff" -- -- >>> showHex (kBitDiff 8 0x20ff 0x10ff) "" -- "1000" --kBitDiff :: Int -> Word16 -> Word16 -> Word16 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16 } where results are bounded from below by 0. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffPos 8 0x0201 0x0101) "" -- "100" -- -- >>> showHex (kBitDiffPos 8 0x0201 0x0102) "" -- "100" -- -- >>> showHex (kBitDiffPos 8 0x20ff 0x10ff) "" -- "1000" --kBitDiffPos :: Int -> Word16 -> Word16 -> Word16 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 } where all the sub-words of x and -- y must not have the signed bit set for the result to be -- meaningful. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffUnsafe 8 0x0201 0x0101) "" -- "100" -- -- >>> showHex (kBitDiffUnsafe 8 0x0201 0x0102) "" -- "1ff" -- -- >>> showHex (kBitDiffUnsafe 8 0x20ff 0x10ff) "" -- produces nonsense in the last sub-word -- "1080" --kBitDiffUnsafe :: Int -> Word16 -> Word16 -> Word16 module HaskellWorks.Data.Bits.Broadword.Word32 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32 } such that the highest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (h 2) "" -- "aaaaaaaa" -- -- >>> showHex (h 4) "" -- "88888888" -- -- >>> showHex (h 8) "" -- "80808080" -- -- >>> showHex (h 16) "" -- "80008000" -- -- >>> showHex (h 32) "" -- "80000000" --h :: Int -> Word32 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32 } such that the lowest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (l 2) "" -- "55555555" -- -- >>> showHex (l 4) "" -- "11111111" -- -- >>> showHex (l 8) "" -- "1010101" -- -- >>> showHex (l 16) "" -- "10001" -- -- >>> showHex (l 32) "" -- "1" --l :: Int -> Word32 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32 }. -- -- The subtraction respects 2's complement so sub-words may be regarded -- as signed or unsigned words. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x04030201 0x02020101) "" -- "2010100" -- -- >>> showHex (kBitDiff 8 0x04030201 0x01020304) "" -- "301fffd" -- -- >>> showHex (kBitDiff 8 0x200000ff 0x100000ff) "" -- "10000000" --kBitDiff :: Int -> Word32 -> Word32 -> Word32 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32 } where results are bounded from below by 0. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffPos 8 0x04030201 0x02020101) "" -- "2010100" -- -- >>> showHex (kBitDiffPos 8 0x04030201 0x01020304) "" -- "3010000" -- -- >>> showHex (kBitDiffPos 8 0x200000ff 0x100000ff) "" -- produces nonsense in the last sub-word -- "10000000" --kBitDiffPos :: Int -> Word32 -> Word32 -> Word32 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32 } where all the sub-words of x and -- y must not have the signed bit set for the result to be -- meaningful. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffUnsafe 8 0x04030201 0x02020101) "" -- "2010100" -- -- >>> showHex (kBitDiffUnsafe 8 0x04030201 0x05060708) "" -- "fffdfbf9" -- -- >>> showHex (kBitDiffUnsafe 8 0x200000ff 0x100000ff) "" -- "10000080" --kBitDiffUnsafe :: Int -> Word32 -> Word32 -> Word32 module HaskellWorks.Data.Bits.Broadword.Word64 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32, 64 } such that the highest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (h 2) "" -- "aaaaaaaaaaaaaaaa" -- -- >>> showHex (h 4) "" -- "8888888888888888" -- -- >>> showHex (h 8) "" -- "8080808080808080" -- -- >>> showHex (h 16) "" -- "8000800080008000" -- -- >>> showHex (h 32) "" -- "8000000080000000" -- -- >>> showHex (h 64) "" -- "8000000000000000" --h :: Int -> Word64 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32, 64 } such that the lowest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (l 2) "" -- "5555555555555555" -- -- >>> showHex (l 4) "" -- "1111111111111111" -- -- >>> showHex (l 8) "" -- "101010101010101" -- -- >>> showHex (l 16) "" -- "1000100010001" -- -- >>> showHex (l 32) "" -- "100000001" -- -- >>> showHex (l 64) "" -- "1" --l :: Int -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 }. -- -- The subtraction respects 2's complement so sub-words may be regarded -- as signed or unsigned words. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiff 8 0x0807060504030201 0x0102030405060708) "" -- "7050301fffdfbf9" -- -- >>> showHex (kBitDiff 8 0x20000000000000ff 0x10000000000000ff) "" -- "1000000000000000" --kBitDiff :: Int -> Word64 -> Word64 -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 } where results are bounded from below by 0. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffPos 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiffPos 8 0x0807060504030201 0x0102030405060708) "" -- "705030100000000" -- -- >>> showHex (kBitDiffPos 8 0x20000000000000ff 0x10000000000000ff) "" -- "1000000000000000" --kBitDiffPos :: Int -> Word64 -> Word64 -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 } where all the sub-words of x and -- y must not have the signed bit set for the result to be -- meaningful. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffUnsafe 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiffUnsafe 8 0x0807060504030201 0x0102030405060708) "" -- "7050301fffdfbf9" -- -- >>> showHex (kBitDiffUnsafe 8 0x20000000000000ff 0x10000000000000ff) "" -- produces nonsense in the last sub-word -- "1000000000000080" --kBitDiffUnsafe :: Int -> Word64 -> Word64 -> Word64 module HaskellWorks.Data.Bits.Broadword.Word8 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32 } such that the highest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (h 2) "" -- "aa" -- -- >>> showHex (h 4) "" -- "88" -- -- >>> showHex (h 8) "" -- "80" --h :: Int -> Word8 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32 } such that the lowest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (l 2) "" -- "55" -- -- >>> showHex (l 4) "" -- "11" -- -- >>> showHex (l 8) "" -- "1" --l :: Int -> Word8 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8 }. -- -- The subtraction respects 2's complement so sub-words may be regarded -- as signed or unsigned words. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x02 0x01) "" -- "1" -- -- >>> showHex (kBitDiff 8 0x01 0x02) "" -- "ff" -- -- >>> showHex (kBitDiff 8 0xff 0xff) "" -- "0" --kBitDiff :: Int -> Word8 -> Word8 -> Word8 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8 } where results are bounded from below by 0. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x02 0x01) "" -- "1" -- -- >>> showHex (kBitDiff 8 0x01 0x02) "" -- "ff" -- -- >>> showHex (kBitDiff 8 0xff 0xff) "" -- "0" --kBitDiffPos :: Int -> Word8 -> Word8 -> Word8 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8 } where all the sub-words of x and y -- must not have the signed bit set for the result to be meaningful. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffUnsafe 8 0x02 0x01) "" -- "1" -- -- >>> showHex (kBitDiffUnsafe 8 0x01 0x02) "" -- "ff" -- -- >>> showHex (kBitDiffUnsafe 8 0xff 0xff) "" -- produces nonsense in the last sub-word -- "80" --kBitDiffUnsafe :: Int -> Word8 -> Word8 -> Word8 module HaskellWorks.Data.Bits.ElemFixedBitSize -- | Class of values that have elements of a fixed bit size -- --
-- >>> elemFixedBitSize (undefined :: DVS.Vector Word8) -- 8 --class ElemFixedBitSize v where { -- | The element type of the elemnet type family Elem v; } -- | Get the bit size of an element for a given composite bit-string type. -- --
-- >>> elemFixedBitSize (undefined :: DVS.Vector Word8) -- 8 --elemFixedBitSize :: ElemFixedBitSize v => v -> Count instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize [GHC.Types.Bool] instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize [GHC.Word.Word8] instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize [GHC.Word.Word16] instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize [GHC.Word.Word32] instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize [GHC.Word.Word64] instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Vector GHC.Types.Bool) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Storable.Vector GHC.Types.Bool) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.ElemFixedBitSize.ElemFixedBitSize (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.FixedBitSize -- | Class of values that have a fix bit size class FixedBitSize a -- | Get the bit size of a value of given type. -- --
-- >>> fixedBitSize (undefined :: Word8) -- 8 --fixedBitSize :: FixedBitSize a => a -> Count instance HaskellWorks.Data.Bits.FixedBitSize.FixedBitSize GHC.Types.Bool instance HaskellWorks.Data.Bits.FixedBitSize.FixedBitSize GHC.Word.Word8 instance HaskellWorks.Data.Bits.FixedBitSize.FixedBitSize GHC.Word.Word16 instance HaskellWorks.Data.Bits.FixedBitSize.FixedBitSize GHC.Word.Word32 instance HaskellWorks.Data.Bits.FixedBitSize.FixedBitSize GHC.Word.Word64 module HaskellWorks.Data.Bits.LoBitsSized class LoBitsSized a -- | Value with the n least significant bits set to 1. loBitsSized :: LoBitsSized a => Count -> a instance HaskellWorks.Data.Bits.LoBitsSized.LoBitsSized GHC.Word.Word64 instance HaskellWorks.Data.Bits.LoBitsSized.LoBitsSized GHC.Word.Word32 instance HaskellWorks.Data.Bits.LoBitsSized.LoBitsSized GHC.Word.Word16 instance HaskellWorks.Data.Bits.LoBitsSized.LoBitsSized GHC.Word.Word8 module HaskellWorks.Data.Bits.Log2 class Log2 a -- | Log base of the given value rounded down to the nearest integer log2 :: Log2 a => a -> Int instance HaskellWorks.Data.Bits.Log2.Log2 GHC.Word.Word64 instance HaskellWorks.Data.Bits.Log2.Log2 GHC.Word.Word32 module HaskellWorks.Data.Bits.Types.Broadword -- | Type wrapper to prefer broadword operations. newtype Broadword a Broadword :: a -> Broadword a instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) instance GHC.Generics.Generic (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) instance Foreign.Storable.Storable a => Foreign.Storable.Storable (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) instance GHC.Show.Show a => GHC.Show.Show (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) instance GHC.Classes.Eq a => GHC.Classes.Eq (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) instance HaskellWorks.Data.Bits.BitWise.BitWise a => HaskellWorks.Data.Bits.BitWise.BitWise (HaskellWorks.Data.Bits.Types.Broadword.Broadword a) module HaskellWorks.Data.Bits.Types.Builtin -- | Type wrapper to prefer builting operations. newtype Builtin a Builtin :: a -> Builtin a instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) instance GHC.Generics.Generic (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) instance Foreign.Storable.Storable a => Foreign.Storable.Storable (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) instance GHC.Show.Show a => GHC.Show.Show (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) instance GHC.Classes.Eq a => GHC.Classes.Eq (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) instance HaskellWorks.Data.Bits.BitWise.BitWise a => HaskellWorks.Data.Bits.BitWise.BitWise (HaskellWorks.Data.Bits.Types.Builtin.Builtin a) module HaskellWorks.Data.Bits.PopCount.PopCount1 class PopCount1 v -- | The number of 1-bits in the value. popCount1 :: PopCount1 v => v -> Count instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 GHC.Types.Bool instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 GHC.Word.Word8 instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 GHC.Word.Word16 instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 GHC.Word.Word32 instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 GHC.Word.Word64 instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 a => HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 [a] instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.PopCount.PopCount1.PopCount1 (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.PopCount.PopCount0 class PopCount0 v -- | The number of 0-bits in the value. popCount0 :: PopCount0 v => v -> Count instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 GHC.Types.Bool instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 GHC.Word.Word8 instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 GHC.Word.Word16 instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 GHC.Word.Word32 instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 GHC.Word.Word64 instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 a => HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 [a] instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Builtin.Builtin GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word8)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word16)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word32)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Storable.Vector (HaskellWorks.Data.Bits.Types.Broadword.Broadword GHC.Word.Word64)) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.PopCount.PopCount0.PopCount0 (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.PopCount module HaskellWorks.Data.Bits.AllExcess.AllExcess1 class AllExcess1 a -- | Number of 1-bits minues the number of 0-bits. allExcess1 :: AllExcess1 a => a -> Int instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 [GHC.Types.Bool] instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 GHC.Word.Word8 instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 GHC.Word.Word16 instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 GHC.Word.Word32 instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 GHC.Word.Word64 instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.AllExcess.AllExcess1.AllExcess1 (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.AllExcess.AllExcess0 class AllExcess0 a -- | Number of 0-bits minues the number of 1-bits. allExcess0 :: AllExcess0 a => a -> Int instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 [GHC.Types.Bool] instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 GHC.Word.Word8 instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 GHC.Word.Word16 instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 GHC.Word.Word32 instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 GHC.Word.Word64 instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.AllExcess.AllExcess0.AllExcess0 (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.AllExcess module HaskellWorks.Data.Bits.Word class WordConcat a where { type family DoubleWords a; } -- | Concatenate two words in little-endian order of the same size into a -- word of twice the size. leConcat :: WordConcat a => a -> a -> DoubleWords a class WordSplit a where { type family HalfWords a; } -- | Split a word equally into two smaller words in little-endian order. leSplit :: WordSplit a => a -> (HalfWords a, HalfWords a) instance HaskellWorks.Data.Bits.Word.WordSplit GHC.Word.Word64 instance HaskellWorks.Data.Bits.Word.WordSplit GHC.Word.Word32 instance HaskellWorks.Data.Bits.Word.WordSplit GHC.Word.Word16 instance HaskellWorks.Data.Bits.Word.WordConcat GHC.Word.Word8 instance HaskellWorks.Data.Bits.Word.WordConcat GHC.Word.Word16 instance HaskellWorks.Data.Bits.Word.WordConcat GHC.Word.Word32 module HaskellWorks.Data.Bits.BitShow -- | Shower of a value as a bit string class BitShow a -- | Show a value as a bit string bitShows :: BitShow a => a -> String -> String bitShow :: BitShow a => a -> String instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Types.Bool instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Word.Word8 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Word.Word16 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Word.Word32 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Word.Word64 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Int.Int8 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Int.Int16 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Int.Int32 instance HaskellWorks.Data.Bits.BitShow.BitShow GHC.Int.Int64 instance HaskellWorks.Data.Bits.BitShow.BitShow [GHC.Types.Bool] instance HaskellWorks.Data.Bits.BitShow.BitShow Data.ByteString.Internal.ByteString instance HaskellWorks.Data.Bits.BitShow.BitShow Data.ByteString.Lazy.Internal.ByteString instance HaskellWorks.Data.Bits.BitShow.BitShow [GHC.Word.Word8] instance HaskellWorks.Data.Bits.BitShow.BitShow [GHC.Word.Word16] instance HaskellWorks.Data.Bits.BitShow.BitShow [GHC.Word.Word32] instance HaskellWorks.Data.Bits.BitShow.BitShow [GHC.Word.Word64] instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.BitShow.BitShow (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.BitShown -- | Tag for a value describe the value as being able to be shown as a bit -- string newtype BitShown a BitShown :: a -> BitShown a [unBitShown] :: BitShown a -> a -- | Show the value as a bit string bitShown :: BitShown a -> a instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (HaskellWorks.Data.Bits.BitShown.BitShown a) instance GHC.Generics.Generic (HaskellWorks.Data.Bits.BitShown.BitShown a) instance HaskellWorks.Data.Bits.BitShow.BitShow a => HaskellWorks.Data.Bits.BitShow.BitShow (HaskellWorks.Data.Bits.BitShown.BitShown a) instance HaskellWorks.Data.Bits.BitRead.BitRead a => HaskellWorks.Data.Bits.BitRead.BitRead (HaskellWorks.Data.Bits.BitShown.BitShown a) instance GHC.Classes.Eq a => GHC.Classes.Eq (HaskellWorks.Data.Bits.BitShown.BitShown a) instance GHC.Base.Functor HaskellWorks.Data.Bits.BitShown.BitShown instance HaskellWorks.Data.Bits.BitWise.TestBit a => HaskellWorks.Data.Bits.BitWise.TestBit (HaskellWorks.Data.Bits.BitShown.BitShown a) instance HaskellWorks.Data.Bits.BitRead.BitRead a => Data.String.IsString (HaskellWorks.Data.Bits.BitShown.BitShown a) instance HaskellWorks.Data.Bits.BitShow.BitShow a => GHC.Show.Show (HaskellWorks.Data.Bits.BitShown.BitShown a) instance HaskellWorks.Data.FromByteString.FromByteString (HaskellWorks.Data.Bits.BitShown.BitShown [GHC.Types.Bool]) module HaskellWorks.Data.Bits module HaskellWorks.Data.Bits.FromBitTextByteString class FromBitTextByteString a -- | Convert a binary byte string to a value of type @a fromBitTextByteString :: FromBitTextByteString a => ByteString -> a instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Storable.Vector GHC.Word.Word8) instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Storable.Vector GHC.Word.Word16) instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Storable.Vector GHC.Word.Word32) instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Storable.Vector GHC.Word.Word64) instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Unboxed.Base.Vector Data.Bit.Internal.Bit) instance HaskellWorks.Data.Bits.FromBitTextByteString.FromBitTextByteString (Data.Vector.Unboxed.Base.Vector Data.Bit.InternalTS.Bit) module HaskellWorks.Data.Bits.Word64 -- | Returns the position of the least significant bit (0-based). -- -- This is equivalent to countTrailingZeros except for when there -- are no bits set. In which case return a word with all bits set. -- --
-- >>> lsb 8 -- 3 -- -- >>> lsb 1 -- 0 -- -- >>> lsb 0 -- 18446744073709551615 --lsb :: Word64 -> Word64 -- | Deprecated: Import the relevant module instead module HaskellWorks.Data.Bits.Broadword newtype Broadword a Broadword :: a -> Broadword a broadword :: Broadword Word64 -> Word64 -- | Returns the position of the least significant bit (0-based). -- -- This is equivalent to countTrailingZeros except for when there -- are no bits set. In which case return a word with all bits set. -- --
-- >>> lsb 8 -- 3 -- -- >>> lsb 1 -- 0 -- -- >>> lsb 0 -- 18446744073709551615 --lsb :: Word64 -> Word64 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32, 64 } such that the highest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (h 2) "" -- "aaaaaaaaaaaaaaaa" -- -- >>> showHex (h 4) "" -- "8888888888888888" -- -- >>> showHex (h 8) "" -- "8080808080808080" -- -- >>> showHex (h 16) "" -- "8000800080008000" -- -- >>> showHex (h 32) "" -- "8000000080000000" -- -- >>> showHex (h 64) "" -- "8000000000000000" --h :: Int -> Word64 -- | Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, -- 32, 64 } such that the lowest bit is set to 1 and all other bits are -- cleared. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (l 2) "" -- "5555555555555555" -- -- >>> showHex (l 4) "" -- "1111111111111111" -- -- >>> showHex (l 8) "" -- "101010101010101" -- -- >>> showHex (l 16) "" -- "1000100010001" -- -- >>> showHex (l 32) "" -- "100000001" -- -- >>> showHex (l 64) "" -- "1" --l :: Int -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 }. -- -- The subtraction respects 2's complement so sub-words may be regarded -- as signed or unsigned words. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiff 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiff 8 0x0807060504030201 0x0102030405060708) "" -- "7050301fffdfbf9" -- -- >>> showHex (kBitDiff 8 0x20000000000000ff 0x10000000000000ff) "" -- "1000000000000000" --kBitDiff :: Int -> Word64 -> Word64 -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 } where results are bounded from below by 0. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffPos 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiffPos 8 0x0807060504030201 0x0102030405060708) "" -- "705030100000000" -- -- >>> showHex (kBitDiffPos 8 0x20000000000000ff 0x10000000000000ff) "" -- "1000000000000000" --kBitDiffPos :: Int -> Word64 -> Word64 -> Word64 -- | Broadword subtraction of sub-words of size k where k -- ∈ { 2, 4, 8, 16, 32, 64 } where all the sub-words of x and -- y must not have the signed bit set for the result to be -- meaningful. -- --
-- >>> import Numeric(showHex) -- -- >>> showHex (kBitDiffUnsafe 8 0x0807060504030201 0x0404030302020101) "" -- "403030202010100" -- -- >>> showHex (kBitDiffUnsafe 8 0x0807060504030201 0x0102030405060708) "" -- "7050301fffdfbf9" -- -- >>> showHex (kBitDiffUnsafe 8 0x20000000000000ff 0x10000000000000ff) "" -- produces nonsense in the last sub-word -- "1000000000000080" --kBitDiffUnsafe :: Int -> Word64 -> Word64 -> Word64 module HaskellWorks.Data.Bits.Writer.Storable data Writer s Writer :: MVector s Word64 -> STRef s Int -> Writer s [vector] :: Writer s -> MVector s Word64 [position] :: Writer s -> STRef s Int full :: Writer s -> ST s Bool newWriter :: Int -> ST s (Writer s) unsafeWriteBit :: Writer s -> Word64 -> ST s () unsafeWriteLoBits :: Writer s -> Int -> Word64 -> ST s () unsafeWriteBits :: Writer s -> Int -> Word64 -> ST s () written :: Writer s -> ST s (MVector s Word64)