IntegralDomain corresponds to a commutative ring,
where a mod b picks a canonical element
of the equivalence class of a in the ideal generated by b.
div and mod satisfy the laws
a * b === b * a
(a `div` b) * b + (a `mod` b) === a
(a+k*b) `mod` b === a `mod` b
0 `mod` b === 0Typical examples of IntegralDomain include integers and
polynomials over a field.
Note that for a field, there is a canonical instance
defined by the above rules; e.g.,
instance IntegralDomain.C Rational where
divMod a b =
if isZero b
then (undefined,a)
else (a\/b,0)It shall be noted, that div, mod, divMod have a parameter order which is unfortunate for partial application. But it is adapted to mathematical conventions, where the operators are used in infix notation.
Instances19C, …
C IntegerDefined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Int16Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Int32Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Int64Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Int8Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Word16Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Word32Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Word64Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC Word8Defined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC IntDefined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC WordDefined in numeric-prelude-0.4.4 · Algebra.IntegralDomainC TDefined in numeric-prelude-0.4.4 · Number.PeanoIntegral a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Wrapper.Haskell98C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Wrapper.NumericPreludeC a => C (T a)Defined in numeric-prelude-0.4.4 · Number.Complex(Ord a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.NonNegative · orphan(Ord a, C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.NonNegativeChunkydivMod is implemented in terms of divModStrict. If it is needed we could also provide a function that accesses the divisor first in a lazy way and then uses a strict divisor for subsequent rounds of the subtraction loop. This way we can handle the cases "dividend smaller than divisor" and "dividend greater than divisor" in a lazy and efficient way. However changing the way of operation within one number is also not nice.
(C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Polynomial(C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.PowerSeries