Safe Haskell | None |
---|---|
Language | Haskell2010 |
Numeric.Data.Internal.Utils
Contents
Description
Internal utils.
Synopsis
- checkModBound :: (AnyUpperBounded a, Integral a, Typeable a) => a -> Integer -> Maybe String
- modSafeAdd :: (AnyUpperBounded a, Integral a) => a -> a -> a -> a
- modSafeMult :: (AnyUpperBounded a, Integral a) => a -> a -> a -> a
- modSafeSub :: (AnyLowerBounded a, Integral a) => a -> a -> a -> a
- rmatching :: (Is (ReversedOptic k) An_AffineTraversal, ReversibleOptic k) => Optic k NoIx b a t s -> s -> Either t a
Safe modular arithmetic
Arguments
:: (AnyUpperBounded a, Integral a, Typeable a) | |
=> a | The type a whose upper bound must be large enough to accommodate modular arithmetic within modulus n. This would be a Proxy except we get a better error message for the value itself. |
-> Integer | The modulus n that should satisfy |
-> Maybe String |
Verifies that the type A is large enough to fit the modulus.
Returns Nothing
if the check succeeds or a String error message if
the check fails.
Arguments
:: (AnyUpperBounded a, Integral a) | |
=> a | x |
-> a | y |
-> a | n (modulus) |
-> a |
Performs modular addition, accounting for rounding in the type itself.
Arguments
:: (AnyUpperBounded a, Integral a) | |
=> a | x |
-> a | y |
-> a | n (modulus) |
-> a |
Performs modular multiplication, accounting for rounding in the type itself.
Arguments
:: (AnyLowerBounded a, Integral a) | |
=> a | x |
-> a | y |
-> a | n (modulus) |
-> a |
Performs modular subtraction, accounting for rounding in the type itself.
Optics
rmatching :: (Is (ReversedOptic k) An_AffineTraversal, ReversibleOptic k) => Optic k NoIx b a t s -> s -> Either t a Source #
Reversed matching
. Useful with smart-constructor optics.
Since: 0.1