Because the division operator for integers has two results (quotient and remainder):
divMod :: Integer -> Integer -> (Integer, Integer)
You can also use the div
operator:
n `div` m
which returns only one component of the division result (the quotient), but that's not the same thing as n / m
. /
is for types where the division operator has only one result which combines 'quotient' and 'remainder' in one fraction.
Equationally, if (q, r) = n `divMod` m
, then
n = m * q + r
whereas if q = x / y
, then
x = y * q
(up to the usual caveats about floating point numbers and approximations).
Substituting div
for /
breaks that relationship, because it throws away some of the information you need to reproduce n
.