numeric-prelude-0.1.3: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
Number.ResidueClass.Check
Synopsis
data T a = Cons {
modulus :: !a
representative :: !a
}
factorPrec :: Int
(/:) :: C a => a -> a -> T a
isCompatible :: Eq a => T a -> T a -> Bool
maybeCompatible :: Eq a => T a -> T a -> Maybe a
fromRepresentative :: C a => a -> a -> T a
lift1 :: Eq a => (a -> a -> a) -> T a -> T a
lift2 :: Eq a => (a -> a -> a -> a) -> T a -> T a -> T a
errIncompat :: a
zero :: C a => a -> T a
one :: C a => a -> T a
fromInteger :: C a => a -> Integer -> T a
Documentation
data T a Source
The best solution seems to let modulus be part of the type. This could happen with a phantom type for modulus and a run function like Control.Monad.ST.runST. Then operations with non-matching moduli could be detected at compile time and zero and one could be generated with the correct modulus. An alternative trial can be found in module ResidueClassMaybe.
Constructors
Cons
modulus :: !a
representative :: !a
show/hide Instances
Eq a => Eq (T a)
(Read a, C a) => Read (T a)
Show a => Show (T a)
(Eq a, C a) => C (T a)
(Eq a, C a) => C (T a)
C a => C (T a)
(Eq a, C a) => C (T a)
factorPrec :: IntSource
(/:) :: C a => a -> a -> T aSource
r /: m is the residue class containing r with respect to the modulus m
isCompatible :: Eq a => T a -> T a -> BoolSource
Check if two residue classes share the same modulus
maybeCompatible :: Eq a => T a -> T a -> Maybe aSource
fromRepresentative :: C a => a -> a -> T aSource
lift1 :: Eq a => (a -> a -> a) -> T a -> T aSource
lift2 :: Eq a => (a -> a -> a -> a) -> T a -> T a -> T aSource
errIncompat :: aSource
zero :: C a => a -> T aSource
one :: C a => a -> T aSource
fromInteger :: C a => a -> Integer -> T aSource
Produced by Haddock version 2.4.2