| Copyright | (c) 2012-2016 Iago Abal (c) 2012-2013 HASLab & University of Minho |
|---|---|
| License | BSD3 |
| Maintainer | Iago Abal <mail@iagoabal.eu> |
| Safe Haskell | None |
| Language | Haskell98 |
Data.BitVector
Description
Bit-vector arithmetic inspired by SMT-LIB http://smt-lib.org/ and Cryptol http://cryptol.net/.
Bit-vectors are represented as a pair size and value,
where sizes are of type Int and values are Integer.
- Bit-vectors are interpreted as unsigned integers (i.e. natural numbers) except for some specific signed operations.
- Most operations are in some way size-polymorphic and, if required, will perform padding to adjust the size of input bit-vectors.
For documentation purposes we will write [n]k to denote a bit-vector
of size n representing the natural number k.
Synopsis
- type BitVector = BV
- data BV
- size :: BV -> Int
- width :: BV -> Int
- nat :: BV -> Integer
- uint :: BV -> Integer
- int :: BV -> Integer
- nil :: BV
- bitVec :: Integral a => Int -> a -> BV
- bitVecs :: Integral a => Int -> [a] -> [BV]
- ones :: Int -> BV
- zeros :: Int -> BV
- isNat :: BV -> Bool
- isPos :: BV -> Bool
- (==.) :: BV -> BV -> Bool
- (/=.) :: BV -> BV -> Bool
- (<.) :: BV -> BV -> Bool
- (<=.) :: BV -> BV -> Bool
- (>.) :: BV -> BV -> Bool
- (>=.) :: BV -> BV -> Bool
- slt :: BV -> BV -> Bool
- sle :: BV -> BV -> Bool
- sgt :: BV -> BV -> Bool
- sge :: BV -> BV -> Bool
- (@.) :: Integral ix => BV -> ix -> Bool
- index :: Integral ix => ix -> BV -> Bool
- (@@) :: Integral ix => BV -> (ix, ix) -> BV
- extract :: Integral ix => ix -> ix -> BV -> BV
- (@:) :: Integral ix => BV -> [ix] -> BV
- (!.) :: Integral ix => BV -> ix -> Bool
- least :: Integral ix => ix -> BV -> BV
- most :: Integral ix => ix -> BV -> BV
- msb :: BV -> Bool
- lsb :: BV -> Bool
- msb1 :: BV -> Int
- lsb1 :: BV -> Int
- signumI :: Integral a => BV -> a
- pow :: Integral exp => BV -> exp -> BV
- sdiv :: BV -> BV -> BV
- srem :: BV -> BV -> BV
- smod :: BV -> BV -> BV
- lg2 :: BV -> BV
- (#) :: BV -> BV -> BV
- cat :: BV -> BV -> BV
- append :: BV -> BV -> BV
- concat :: [BV] -> BV
- zeroExtend :: Integral size => size -> BV -> BV
- signExtend :: Integral size => size -> BV -> BV
- foldl :: (a -> Bool -> a) -> a -> BV -> a
- foldl_ :: (a -> Bool -> a) -> a -> BV -> a
- foldr :: (Bool -> a -> a) -> a -> BV -> a
- foldr_ :: (Bool -> a -> a) -> a -> BV -> a
- reverse :: BV -> BV
- reverse_ :: BV -> BV
- replicate :: Integral size => size -> BV -> BV
- replicate_ :: Integral size => size -> BV -> BV
- and :: [BV] -> BV
- and_ :: [BV] -> BV
- or :: [BV] -> BV
- or_ :: [BV] -> BV
- split :: Integral times => times -> BV -> [BV]
- group :: Integral size => size -> BV -> [BV]
- group_ :: Integral size => size -> BV -> [BV]
- join :: [BV] -> BV
- class Eq a => Bits a where
- (.&.) :: a -> a -> a
- (.|.) :: a -> a -> a
- xor :: a -> a -> a
- complement :: a -> a
- shift :: a -> Int -> a
- rotate :: a -> Int -> a
- zeroBits :: a
- bit :: Int -> a
- setBit :: a -> Int -> a
- clearBit :: a -> Int -> a
- complementBit :: a -> Int -> a
- testBit :: a -> Int -> Bool
- bitSizeMaybe :: a -> Maybe Int
- bitSize :: a -> Int
- isSigned :: a -> Bool
- shiftL :: a -> Int -> a
- unsafeShiftL :: a -> Int -> a
- shiftR :: a -> Int -> a
- unsafeShiftR :: a -> Int -> a
- rotateL :: a -> Int -> a
- rotateR :: a -> Int -> a
- popCount :: a -> Int
- bitDefault :: (Bits a, Num a) => Int -> a
- popCountDefault :: (Bits a, Num a) => a -> Int
- testBitDefault :: (Bits a, Num a) => a -> Int -> Bool
- toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
- (!<<.) :: Bits a => a -> Int -> a
- (!>>.) :: Bits a => a -> Int -> a
- (.<<.) :: Bits a => a -> Int -> a
- (.>>.) :: Bits a => a -> Int -> a
- (.^.) :: Bits a => a -> a -> a
- oneBits :: FiniteBits a => a
- class Bits b => FiniteBits b where
- finiteBitSize :: b -> Int
- countLeadingZeros :: b -> Int
- countTrailingZeros :: b -> Int
- newtype And a = And {
- getAnd :: a
- newtype Iff a = Iff {
- getIff :: a
- newtype Ior a = Ior {
- getIor :: a
- newtype Xor a = Xor {
- getXor :: a
- not :: BV -> BV
- not_ :: BV -> BV
- nand :: BV -> BV -> BV
- nor :: BV -> BV -> BV
- xnor :: BV -> BV -> BV
- (<<.) :: BV -> BV -> BV
- shl :: BV -> BV -> BV
- (>>.) :: BV -> BV -> BV
- shr :: BV -> BV -> BV
- ashr :: BV -> BV -> BV
- (<<<.) :: BV -> BV -> BV
- rol :: BV -> BV -> BV
- (>>>.) :: BV -> BV -> BV
- ror :: BV -> BV -> BV
- fromBool :: Bool -> BV
- fromBits :: [Bool] -> BV
- toBits :: BV -> [Bool]
- showBin :: BV -> String
- showOct :: BV -> String
- showHex :: BV -> String
Bit-vectors
Big-endian pseudo size-polymorphic bit-vectors.
Instances
| Monoid BV Source # | |
| Semigroup BV Source # | |
| Bits BV Source # | |
Defined in Data.BitVector Methods complement :: BV -> BV # complementBit :: BV -> Int -> BV # testBit :: BV -> Int -> Bool # bitSizeMaybe :: BV -> Maybe Int # unsafeShiftL :: BV -> Int -> BV # unsafeShiftR :: BV -> Int -> BV # | |
| Data BV Source # | |
Defined in Data.BitVector Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BV -> c BV gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BV dataTypeOf :: BV -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BV) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BV) gmapT :: (forall b. Data b => b -> b) -> BV -> BV gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BV -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BV -> r gmapQ :: (forall d. Data d => d -> u) -> BV -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> BV -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> BV -> m BV gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BV -> m BV gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BV -> m BV | |
| Enum BV Source # | |
| Num BV Source # | |
| Read BV Source # | |
Defined in Data.BitVector | |
| Integral BV Source # | |
| Real BV Source # | |
Defined in Data.BitVector Methods toRational :: BV -> Rational | |
| Show BV Source # | |
| Eq BV Source # | |
| Ord BV Source # | |
Creation
bitVec :: Integral a => Int -> a -> BV Source #
Create a bit-vector given a size and an integer value.
>>>bitVec 4 3[4]3
This function also handles negative values.
>>>bitVec 4 (-1)[4]15
bitVecs :: Integral a => Int -> [a] -> [BV] Source #
List of bit-vector literals of the same size
When a list of integer literals is interpreted as a list of bit-vectors,
fromInteger is applied to each element invidually:
>>>[1,3,5] :: [BV][ [1]1, [2]3, [3]5 ]
Sometimes we want to specify a list of bit-vectors literals of the same
size, and for that we can use bitVects:
>>>bitVecs 3 [1,3,5][ [3]1, [3]3, [3]5 ]
Test
Comparison
(==.) :: BV -> BV -> Bool infix 4 Source #
Fixed-size equality.
In contrast with ==, which is size-polymorphic, this equality
requires both bit-vectors to be of equal size.
>>>[n]k ==. [m]kFalse
>>>[n]k ==. [n]kTrue
Indexing
(@.) :: Integral ix => BV -> ix -> Bool infixl 9 Source #
Bit indexing.
u @. i stands for the i-th bit of u.
>>>[4]2 @. 0False
>>>[4]2 @. 1True
(@@) :: Integral ix => BV -> (ix, ix) -> BV infixl 9 Source #
Bit-string extraction.
u @@ (j,i) == fromBits (map (u @.) [j,j-1..i])
>>>[4]7 @@ (3,1)[3]3
(@:) :: Integral ix => BV -> [ix] -> BV infixl 9 Source #
Bit list indexing.
u @: is ==. fromBits $ List.map (u @.) is
(!.) :: Integral ix => BV -> ix -> Bool infixl 9 Source #
Reverse bit-indexing.
Index starting from the most significant bit.
u !. i == u @. (size u - i - 1)
>>>[3]3 !. 0False
least :: Integral ix => ix -> BV -> BV Source #
Take least significant bits.
least m u == u @@ (m-1,0)
Most significant 1-bit.
Pre: input must be non-zero.
>>>msb1 [4]21
>>>msb1 [4]42
Least significant 1-bit.
Pre: input must be non-zero.
>>>msb1 [4]30
>>>msb1 [4]61
Arithmetic
pow :: Integral exp => BV -> exp -> BV Source #
Bit-vector exponentiation.
pow [n]k e computes k raised to e modulo n.
This is faster than Haskell's (^) operator because it performs
modulo division just once. Besides, a^0 == [1]0 !!!
List-like operations
cat :: BV -> BV -> BV Source #
Deprecated: Use (#) or append instead
Concatenation of two bit-vectors.
zeroExtend :: Integral size => size -> BV -> BV Source #
Logical extension.
>>>zeroExtend 3 [1]1[4]1
signExtend :: Integral size => size -> BV -> BV Source #
Arithmetic extension.
>>>signExtend 2 [2]1[4]1
>>>signExtend 2 [2]3[4]15
foldl :: (a -> Bool -> a) -> a -> BV -> a Source #
foldl f z (fromBits [un, ..., u1, u0]) == ((((z `f` un) `f` ...) `f` u1) `f` u0)
foldl f e = fromBits . foldl f e . toBits
foldl_ :: (a -> Bool -> a) -> a -> BV -> a Source #
Deprecated: Use corresponding versions without underscore
foldl f z (fromBits [un, ..., u1, u0]) == ((((z `f` un) `f` ...) `f` u1) `f` u0)
foldl f e = fromBits . foldl f e . toBits
foldr :: (Bool -> a -> a) -> a -> BV -> a Source #
foldr f z (fromBits [un, ..., u1, u0]) == un `f` (... `f` (u1 `f` (u0 `f` z)))
foldr f e = fromBits . foldr f e . toBits
foldr_ :: (Bool -> a -> a) -> a -> BV -> a Source #
Deprecated: Use corresponding versions without underscore
foldr f z (fromBits [un, ..., u1, u0]) == un `f` (... `f` (u1 `f` (u0 `f` z)))
foldr f e = fromBits . foldr f e . toBits
Deprecated: Use corresponding versions without underscore
reverse == fromBits . reverse . toBits
replicate :: Integral size => size -> BV -> BV Source #
Pre: if replicate_ n u then n > 0 must hold.
replicate_ n == fromBits . concat . replicate n . toBits
replicate_ :: Integral size => size -> BV -> BV Source #
Deprecated: Use corresponding versions without underscore
Pre: if replicate_ n u then n > 0 must hold.
replicate_ n == fromBits . concat . replicate n . toBits
Conjunction.
Essentially, and == foldr1 (.&.).
Returns [1]1 if the input list is empty.
Deprecated: Use corresponding versions without underscore
Conjunction.
Essentially, and == foldr1 (.&.).
Returns [1]1 if the input list is empty.
Disjunction.
Essentially, or == foldr1 (.|.).
Returns [1]0 if the input list is empty.
Deprecated: Use corresponding versions without underscore
Disjunction.
Essentially, or == foldr1 (.|.).
Returns [1]0 if the input list is empty.
split :: Integral times => times -> BV -> [BV] Source #
Split a bit-vector k times.
>>>split 3 [4]15[[2]0,[2]3,[2]3]
group :: Integral size => size -> BV -> [BV] Source #
Split a bit-vector into n-wide pieces.
>>>group 3 [4]15[[3]1,[3]7]
group_ :: Integral size => size -> BV -> [BV] Source #
Deprecated: Use corresponding versions without underscore
Split a bit-vector into n-wide pieces.
>>>group 3 [4]15[[3]1,[3]7]
Concatenate a (possibly empty) list of bit-vectors.
>>>join [[2]3,[2]2][4]14
Bitwise operations
Minimal complete definition
(.&.), (.|.), xor, complement, (shift | shiftL, shiftR), (rotate | rotateL, rotateR), bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount
Methods
complement :: a -> a #
complementBit :: a -> Int -> a #
bitSizeMaybe :: a -> Maybe Int #
unsafeShiftL :: a -> Int -> a #
unsafeShiftR :: a -> Int -> a #
Instances
| Bits BV Source # | |
Defined in Data.BitVector Methods complement :: BV -> BV # complementBit :: BV -> Int -> BV # testBit :: BV -> Int -> Bool # bitSizeMaybe :: BV -> Maybe Int # unsafeShiftL :: BV -> Int -> BV # unsafeShiftR :: BV -> Int -> BV # | |
| Bits Integer | |
Defined in GHC.Internal.Bits Methods (.&.) :: Integer -> Integer -> Integer # (.|.) :: Integer -> Integer -> Integer # xor :: Integer -> Integer -> Integer # complement :: Integer -> Integer # shift :: Integer -> Int -> Integer # rotate :: Integer -> Int -> Integer # setBit :: Integer -> Int -> Integer # clearBit :: Integer -> Int -> Integer # complementBit :: Integer -> Int -> Integer # testBit :: Integer -> Int -> Bool # bitSizeMaybe :: Integer -> Maybe Int # shiftL :: Integer -> Int -> Integer # unsafeShiftL :: Integer -> Int -> Integer # shiftR :: Integer -> Int -> Integer # unsafeShiftR :: Integer -> Int -> Integer # rotateL :: Integer -> Int -> Integer # | |
| Bits Natural | |
Defined in GHC.Internal.Bits Methods (.&.) :: Natural -> Natural -> Natural # (.|.) :: Natural -> Natural -> Natural # xor :: Natural -> Natural -> Natural # complement :: Natural -> Natural # shift :: Natural -> Int -> Natural # rotate :: Natural -> Int -> Natural # setBit :: Natural -> Int -> Natural # clearBit :: Natural -> Int -> Natural # complementBit :: Natural -> Int -> Natural # testBit :: Natural -> Int -> Bool # bitSizeMaybe :: Natural -> Maybe Int # shiftL :: Natural -> Int -> Natural # unsafeShiftL :: Natural -> Int -> Natural # shiftR :: Natural -> Int -> Natural # unsafeShiftR :: Natural -> Int -> Natural # rotateL :: Natural -> Int -> Natural # | |
| Bits Bool | |
Defined in GHC.Internal.Bits Methods (.&.) :: Bool -> Bool -> Bool # (.|.) :: Bool -> Bool -> Bool # complement :: Bool -> Bool # shift :: Bool -> Int -> Bool # rotate :: Bool -> Int -> Bool # setBit :: Bool -> Int -> Bool # clearBit :: Bool -> Int -> Bool # complementBit :: Bool -> Int -> Bool # testBit :: Bool -> Int -> Bool # bitSizeMaybe :: Bool -> Maybe Int # shiftL :: Bool -> Int -> Bool # unsafeShiftL :: Bool -> Int -> Bool # shiftR :: Bool -> Int -> Bool # unsafeShiftR :: Bool -> Int -> Bool # rotateL :: Bool -> Int -> Bool # | |
| Bits Int | |
Defined in GHC.Internal.Bits Methods complement :: Int -> Int # clearBit :: Int -> Int -> Int # complementBit :: Int -> Int -> Int # testBit :: Int -> Int -> Bool # bitSizeMaybe :: Int -> Maybe Int # unsafeShiftL :: Int -> Int -> Int # unsafeShiftR :: Int -> Int -> Int # rotateL :: Int -> Int -> Int # | |
| Bits Word | |
Defined in GHC.Internal.Bits Methods (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |
| Bits a => Bits (And a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: And a -> And a -> And a # (.|.) :: And a -> And a -> And a # xor :: And a -> And a -> And a # complement :: And a -> And a # shift :: And a -> Int -> And a # rotate :: And a -> Int -> And a # setBit :: And a -> Int -> And a # clearBit :: And a -> Int -> And a # complementBit :: And a -> Int -> And a # testBit :: And a -> Int -> Bool # bitSizeMaybe :: And a -> Maybe Int # shiftL :: And a -> Int -> And a # unsafeShiftL :: And a -> Int -> And a # shiftR :: And a -> Int -> And a # unsafeShiftR :: And a -> Int -> And a # rotateL :: And a -> Int -> And a # | |
| Bits a => Bits (Iff a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Iff a -> Iff a -> Iff a # (.|.) :: Iff a -> Iff a -> Iff a # xor :: Iff a -> Iff a -> Iff a # complement :: Iff a -> Iff a # shift :: Iff a -> Int -> Iff a # rotate :: Iff a -> Int -> Iff a # setBit :: Iff a -> Int -> Iff a # clearBit :: Iff a -> Int -> Iff a # complementBit :: Iff a -> Int -> Iff a # testBit :: Iff a -> Int -> Bool # bitSizeMaybe :: Iff a -> Maybe Int # shiftL :: Iff a -> Int -> Iff a # unsafeShiftL :: Iff a -> Int -> Iff a # shiftR :: Iff a -> Int -> Iff a # unsafeShiftR :: Iff a -> Int -> Iff a # rotateL :: Iff a -> Int -> Iff a # | |
| Bits a => Bits (Ior a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Ior a -> Ior a -> Ior a # (.|.) :: Ior a -> Ior a -> Ior a # xor :: Ior a -> Ior a -> Ior a # complement :: Ior a -> Ior a # shift :: Ior a -> Int -> Ior a # rotate :: Ior a -> Int -> Ior a # setBit :: Ior a -> Int -> Ior a # clearBit :: Ior a -> Int -> Ior a # complementBit :: Ior a -> Int -> Ior a # testBit :: Ior a -> Int -> Bool # bitSizeMaybe :: Ior a -> Maybe Int # shiftL :: Ior a -> Int -> Ior a # unsafeShiftL :: Ior a -> Int -> Ior a # shiftR :: Ior a -> Int -> Ior a # unsafeShiftR :: Ior a -> Int -> Ior a # rotateL :: Ior a -> Int -> Ior a # | |
| Bits a => Bits (Xor a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Xor a -> Xor a -> Xor a # (.|.) :: Xor a -> Xor a -> Xor a # xor :: Xor a -> Xor a -> Xor a # complement :: Xor a -> Xor a # shift :: Xor a -> Int -> Xor a # rotate :: Xor a -> Int -> Xor a # setBit :: Xor a -> Int -> Xor a # clearBit :: Xor a -> Int -> Xor a # complementBit :: Xor a -> Int -> Xor a # testBit :: Xor a -> Int -> Bool # bitSizeMaybe :: Xor a -> Maybe Int # shiftL :: Xor a -> Int -> Xor a # unsafeShiftL :: Xor a -> Int -> Xor a # shiftR :: Xor a -> Int -> Xor a # unsafeShiftR :: Xor a -> Int -> Xor a # rotateL :: Xor a -> Int -> Xor a # | |
| Bits a => Bits (Down a) | |
Defined in GHC.Internal.Data.Ord Methods (.&.) :: Down a -> Down a -> Down a # (.|.) :: Down a -> Down a -> Down a # xor :: Down a -> Down a -> Down a # complement :: Down a -> Down a # shift :: Down a -> Int -> Down a # rotate :: Down a -> Int -> Down a # setBit :: Down a -> Int -> Down a # clearBit :: Down a -> Int -> Down a # complementBit :: Down a -> Int -> Down a # testBit :: Down a -> Int -> Bool # bitSizeMaybe :: Down a -> Maybe Int # shiftL :: Down a -> Int -> Down a # unsafeShiftL :: Down a -> Int -> Down a # shiftR :: Down a -> Int -> Down a # unsafeShiftR :: Down a -> Int -> Down a # rotateL :: Down a -> Int -> Down a # | |
bitDefault :: (Bits a, Num a) => Int -> a #
popCountDefault :: (Bits a, Num a) => a -> Int #
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool #
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b #
oneBits :: FiniteBits a => a #
class Bits b => FiniteBits b where #
Minimal complete definition
Instances
Instances
| FiniteBits a => Monoid (And a) | |
| Bits a => Semigroup (And a) | |
| Bits a => Bits (And a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: And a -> And a -> And a # (.|.) :: And a -> And a -> And a # xor :: And a -> And a -> And a # complement :: And a -> And a # shift :: And a -> Int -> And a # rotate :: And a -> Int -> And a # setBit :: And a -> Int -> And a # clearBit :: And a -> Int -> And a # complementBit :: And a -> Int -> And a # testBit :: And a -> Int -> Bool # bitSizeMaybe :: And a -> Maybe Int # shiftL :: And a -> Int -> And a # unsafeShiftL :: And a -> Int -> And a # shiftR :: And a -> Int -> And a # unsafeShiftR :: And a -> Int -> And a # rotateL :: And a -> Int -> And a # | |
| FiniteBits a => FiniteBits (And a) | |
Defined in GHC.Internal.Data.Bits Methods finiteBitSize :: And a -> Int # countLeadingZeros :: And a -> Int # countTrailingZeros :: And a -> Int # | |
| Bounded a => Bounded (And a) | |
Defined in GHC.Internal.Data.Bits | |
| Enum a => Enum (And a) | |
| Read a => Read (And a) | |
Defined in GHC.Internal.Data.Bits | |
| Show a => Show (And a) | |
| Eq a => Eq (And a) | |
Instances
| FiniteBits a => Monoid (Iff a) | |
| FiniteBits a => Semigroup (Iff a) | |
| Bits a => Bits (Iff a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Iff a -> Iff a -> Iff a # (.|.) :: Iff a -> Iff a -> Iff a # xor :: Iff a -> Iff a -> Iff a # complement :: Iff a -> Iff a # shift :: Iff a -> Int -> Iff a # rotate :: Iff a -> Int -> Iff a # setBit :: Iff a -> Int -> Iff a # clearBit :: Iff a -> Int -> Iff a # complementBit :: Iff a -> Int -> Iff a # testBit :: Iff a -> Int -> Bool # bitSizeMaybe :: Iff a -> Maybe Int # shiftL :: Iff a -> Int -> Iff a # unsafeShiftL :: Iff a -> Int -> Iff a # shiftR :: Iff a -> Int -> Iff a # unsafeShiftR :: Iff a -> Int -> Iff a # rotateL :: Iff a -> Int -> Iff a # | |
| FiniteBits a => FiniteBits (Iff a) | |
Defined in GHC.Internal.Data.Bits Methods finiteBitSize :: Iff a -> Int # countLeadingZeros :: Iff a -> Int # countTrailingZeros :: Iff a -> Int # | |
| Bounded a => Bounded (Iff a) | |
Defined in GHC.Internal.Data.Bits | |
| Enum a => Enum (Iff a) | |
| Read a => Read (Iff a) | |
Defined in GHC.Internal.Data.Bits | |
| Show a => Show (Iff a) | |
| Eq a => Eq (Iff a) | |
Instances
| Bits a => Monoid (Ior a) | |
| Bits a => Semigroup (Ior a) | |
| Bits a => Bits (Ior a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Ior a -> Ior a -> Ior a # (.|.) :: Ior a -> Ior a -> Ior a # xor :: Ior a -> Ior a -> Ior a # complement :: Ior a -> Ior a # shift :: Ior a -> Int -> Ior a # rotate :: Ior a -> Int -> Ior a # setBit :: Ior a -> Int -> Ior a # clearBit :: Ior a -> Int -> Ior a # complementBit :: Ior a -> Int -> Ior a # testBit :: Ior a -> Int -> Bool # bitSizeMaybe :: Ior a -> Maybe Int # shiftL :: Ior a -> Int -> Ior a # unsafeShiftL :: Ior a -> Int -> Ior a # shiftR :: Ior a -> Int -> Ior a # unsafeShiftR :: Ior a -> Int -> Ior a # rotateL :: Ior a -> Int -> Ior a # | |
| FiniteBits a => FiniteBits (Ior a) | |
Defined in GHC.Internal.Data.Bits Methods finiteBitSize :: Ior a -> Int # countLeadingZeros :: Ior a -> Int # countTrailingZeros :: Ior a -> Int # | |
| Bounded a => Bounded (Ior a) | |
Defined in GHC.Internal.Data.Bits | |
| Enum a => Enum (Ior a) | |
| Read a => Read (Ior a) | |
Defined in GHC.Internal.Data.Bits | |
| Show a => Show (Ior a) | |
| Eq a => Eq (Ior a) | |
Instances
| Bits a => Monoid (Xor a) | |
| Bits a => Semigroup (Xor a) | |
| Bits a => Bits (Xor a) | |
Defined in GHC.Internal.Data.Bits Methods (.&.) :: Xor a -> Xor a -> Xor a # (.|.) :: Xor a -> Xor a -> Xor a # xor :: Xor a -> Xor a -> Xor a # complement :: Xor a -> Xor a # shift :: Xor a -> Int -> Xor a # rotate :: Xor a -> Int -> Xor a # setBit :: Xor a -> Int -> Xor a # clearBit :: Xor a -> Int -> Xor a # complementBit :: Xor a -> Int -> Xor a # testBit :: Xor a -> Int -> Bool # bitSizeMaybe :: Xor a -> Maybe Int # shiftL :: Xor a -> Int -> Xor a # unsafeShiftL :: Xor a -> Int -> Xor a # shiftR :: Xor a -> Int -> Xor a # unsafeShiftR :: Xor a -> Int -> Xor a # rotateL :: Xor a -> Int -> Xor a # | |
| FiniteBits a => FiniteBits (Xor a) | |
Defined in GHC.Internal.Data.Bits Methods finiteBitSize :: Xor a -> Int # countLeadingZeros :: Xor a -> Int # countTrailingZeros :: Xor a -> Int # | |
| Bounded a => Bounded (Xor a) | |
Defined in GHC.Internal.Data.Bits | |
| Enum a => Enum (Xor a) | |
| Read a => Read (Xor a) | |
Defined in GHC.Internal.Data.Bits | |
| Show a => Show (Xor a) | |
| Eq a => Eq (Xor a) | |
Deprecated: Use corresponding versions without underscore
An alias for complement.
Conversion
fromBits :: [Bool] -> BV Source #
Create a bit-vector from a big-endian list of bits.
>>>fromBits [False, False, True][3]1
toBits :: BV -> [Bool] Source #
Create a big-endian list of bits from a bit-vector.
>>>toBits [4]11[True, False, True, True]