Copyright | (c) Sirui Lu 2021-2023 |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | siruilu@cs.washington.edu |
Stability | Experimental |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- class Bits a => SymShift a where
- symShift :: a -> a -> a
- symShiftNegated :: a -> a -> a
- newtype DefaultFiniteBitsSymShift a = DefaultFiniteBitsSymShift {}
Documentation
class Bits a => SymShift a where Source #
A class for shifting operations.
The symShift
function shifts the value to the left if the shift amount is
positive, and to the right if the shift amount is negative. If shifting
beyond the bit width of the value, the result is the same as shifting with
the bit width.
The symShiftNegated
function shifts the value to the right if the shift
amount is positive, and to the left if the shift amount is negative. This
function is introduced to handle the asymmetry of the range of values.
Instances
SymShift Int16 Source # | |
SymShift Int32 Source # | |
SymShift Int64 Source # | |
SymShift Int8 Source # | |
SymShift Word16 Source # | |
SymShift Word32 Source # | |
SymShift Word64 Source # | |
SymShift Word8 Source # | |
SymShift Int Source # | |
SymShift Word Source # | |
(Integral a, FiniteBits a) => SymShift (DefaultFiniteBitsSymShift a) Source # | |
(KnownNat n, 1 <= n) => SymShift (IntN n) Source # | |
(KnownNat n, 1 <= n) => SymShift (WordN n) Source # | |
(forall (n :: Nat). (KnownNat n, 1 <= n) => SymShift (bv n), forall (n :: Nat). (KnownNat n, 1 <= n) => Num (bv n), MaySomeBV bv) => SymShift (SomeBV bv) Source # | |
(KnownNat n, 1 <= n) => SymShift (SymIntN n) Source # | |
(KnownNat n, 1 <= n) => SymShift (SymWordN n) Source # | |
newtype DefaultFiniteBitsSymShift a Source #
A newtype wrapper. Use this to derive SymShift
for types that have
FiniteBits
instances.