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 (MonadError e m, TryMerge m, Mergeable a) => SafeSymShift e a m where
- safeSymShiftL :: a -> a -> m a
- safeSymShiftR :: a -> a -> m a
- safeSymStrictShiftL :: a -> a -> m a
- safeSymStrictShiftR :: a -> a -> m a
Documentation
class (MonadError e m, TryMerge m, Mergeable a) => SafeSymShift e a m where Source #
Safe version for shiftL
or shiftR
.
The safeSymShiftL
and safeSymShiftR
are defined for all non-negative
shift amounts.
- Shifting by negative shift amounts is an error.
- The result is defined to be 0 when shifting left by more than or equal to the bit size of the number.
- The result is defined to be 0 when shifting right by more than or equal to the bit size of the number and the number is unsigned or signed non-negative.
- The result is defined to be -1 when shifting right by more than or equal to the bit size of the number and the number is signed negative.
The safeSymStrictShiftL
and safeSymStrictShiftR
are defined for all
non-negative shift amounts that is less than the bit size. Shifting by more
than or equal to the bit size is an error, otherwise they are the same as the
non-strict versions.
safeSymShiftL :: a -> a -> m a Source #
safeSymShiftR :: a -> a -> m a Source #
safeSymStrictShiftL :: a -> a -> m a Source #
safeSymStrictShiftR :: a -> a -> m a Source #