| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Numeric.Data.Internal.Utils
Description
Internal utils.
Synopsis
- checkModBoundAlgebra :: (ToInteger a, MaybeUpperBounded a, Typeable a) => a -> Integer -> Maybe String
- modSafeAddAlgebra :: (ASemigroup a, FromInteger a, MEuclidean a, MaybeUpperBounded a, ToInteger a) => a -> a -> a -> a
- modSafeMultAlgebra :: (FromInteger a, MEuclidean a, MaybeUpperBounded a, ToInteger a) => a -> a -> a -> a
- modSafeSubAlgebra :: (ASemigroup a, FromInteger a, MEuclidean a, ToInteger a, MaybeUpperBounded a) => a -> a -> a -> a
- rmatching :: (Is (ReversedOptic k) An_AffineTraversal, ReversibleOptic k) => Optic k NoIx b a t s -> s -> Either t a
- liftErrorTH :: Lift a => Either String a -> Code Q a
Safe modular arithmetic
Algebra-simple
Arguments
| :: (ToInteger a, MaybeUpperBounded 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
| :: (ASemigroup a, FromInteger a, MEuclidean a, MaybeUpperBounded a, ToInteger a) | |
| => a | x |
| -> a | y |
| -> a | n (modulus) |
| -> a |
Performs modular addition, accounting for rounding in the type itself.
Arguments
| :: (FromInteger a, MEuclidean a, MaybeUpperBounded a, ToInteger a) | |
| => a | x |
| -> a | y |
| -> a | n (modulus) |
| -> a |
Performs modular multiplication, accounting for rounding in the type itself.
Arguments
| :: (ASemigroup a, FromInteger a, MEuclidean a, ToInteger a, MaybeUpperBounded 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