
We went round and round on this back in August.
The ultimate decision was to leave the existing behavior for quot and div
as sufficient consensus for changing it was not reached.
I've updated the ticket in question to reflect that resolution.
-Edward
On Mon, Jun 1, 2015 at 6:40 PM, Nikita Karetnikov
According to the documentation, rem and mod must satisfy the following laws:
-- > (x `quot` y)*y + (x `rem` y) == x rem
-- > (x `div` y)*y + (x `mod` y) == x mod
https://hackage.haskell.org/package/base-4.8.0.0/docs/src/GHC-Real.html
Note, however, that there is a case when quot and div result in an arithmetic overflow:
Prelude> (minBound :: Int) `quot` (-1) *** Exception: arithmetic overflow Prelude> (minBound :: Int) `div` (-1) *** Exception: arithmetic overflow
while rem and mod don't:
Prelude> (minBound :: Int) `rem` (-1) 0 Prelude> (minBound :: Int) `mod` (-1) 0
Is this a mistake?
For the record, I'm aware of the safeint package, which raises the error for rem and mod, and this ticket:
https://ghc.haskell.org/trac/ghc/ticket/8695 _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users