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