Safe Haskell  None 

Language  Haskell98 
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
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 runST
.
Then operations with nonmatching 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.
Cons infix 7  

factorPrec :: Int Source #
(/:) :: C a => a > a > T a infix 7 Source #
r /: m
is the residue class containing r
with respect to the modulus m
isCompatible :: Eq a => T a > T a > Bool Source #
Check if two residue classes share the same modulus
fromRepresentative :: C a => a > a > T a Source #
errIncompat :: a Source #