This data type represents integers modulo m, equipped with useful instances.
For example, 3 :: Mod 10 stands for the class of integers
congruent to 3 \bmod 10 \colon \ldots {−17}, −7, 3, 13, 23 \ldots
:set -XDataKinds3 + 8 :: Mod 10 -- 3 + 8 = 11 ≡ 1 (mod 10)1
Note: Mod 0 has no inhabitants, eventhough \mathbb{Z}/0\mathbb{Z} is technically isomorphic to \mathbb{Z} .
Instances24Bounded, Enum, Eq, Fractional, Num, Ord, …
KnownNat m => Vector Vector (Mod m)Defined in mod-0.2.0.1 · Data.ModNo validation checks are performed; reading untrusted data may corrupt internal invariants.
KnownNat m => MVector MVector (Mod m)Defined in mod-0.2.0.1 · Data.ModNo validation checks are performed; reading untrusted data may corrupt internal invariants.
KnownNat m => Bounded (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Enum (Mod m)Defined in mod-0.2.0.1 · Data.ModEq (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Fractional (Mod m)Defined in mod-0.2.0.1 · Data.ModDivision by a residue, which is not coprime with the modulus, throws DivideByZero. Consider using invertMod for non-prime moduli.
KnownNat m => Num (Mod m)Defined in mod-0.2.0.1 · Data.ModOrd (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Read (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Real (Mod m)Defined in mod-0.2.0.1 · Data.ModShow (Mod m)Defined in mod-0.2.0.1 · Data.ModGeneric (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Storable (Mod m)Defined in mod-0.2.0.1 · Data.ModNo validation checks are performed; reading untrusted data may corrupt internal invariants.
NFData (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Prim (Mod m)Defined in mod-0.2.0.1 · Data.ModNo validation checks are performed; reading untrusted data may corrupt internal invariants.
KnownNat m => Unbox (Mod m)Defined in mod-0.2.0.1 · Data.ModNo validation checks are performed; reading untrusted data may corrupt internal invariants.
KnownNat m => Euclidean (Mod m)Defined in mod-0.2.0.1 · Data.ModMod
mis not even an integral domain for compositem, much less a Euclidean domain.The instance is lawful only for prime
m, otherwise we try to do our best:quot x yreturns anyzsuch thatx == y * z, rem is not always 0, and both can throw DivideByZero.KnownNat m => Field (Mod m)Defined in mod-0.2.0.1 · Data.ModMod
mis not even an integral domain for compositem, much less a field.The instance is lawful only for prime
m, otherwise division by a residue, which is not coprime with the modulus, throws DivideByZero. Consider using invertMod for non-prime moduli.KnownNat m => GcdDomain (Mod m)Defined in mod-0.2.0.1 · Data.ModMod
mis not even an integral domain for compositem, much less a GCD domain. However, gcd and lcm are still meaningful even for compositem, corresponding to a sum and an intersection of ideals.The instance is lawful only for prime
m, otherwisedivide x ytries to return anyJust zsuch thatx == y * z.KnownNat m => Semiring (Mod m)Defined in mod-0.2.0.1 · Data.ModKnownNat m => Ring (Mod m)Defined in mod-0.2.0.1 · Data.Modtype Rep (Mod m) = D1 ('MetaDataDefined in mod-0.2.0.1 · Data.Mod"Mod"
"Data.Mod"
"mod-0.2.0.1-9dF6mWbkkfOFPRbP3H3cXx"
'True) (C1 ('MetaCons"Mod"
'PrefixI 'True) (S1 ('MetaSel ('Just"unMod"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))data MVector s (Mod m)Defined in mod-0.2.0.1 · Data.ModUnboxed vectors of Mod cause more nursery allocations than boxed ones, but reduce pressure on the garbage collector, especially for large vectors.
data Vector (Mod m)Defined in mod-0.2.0.1 · Data.ModUnboxed vectors of Mod cause more nursery allocations than boxed ones, but reduce pressure on the garbage collector, especially for large vectors.