Discussion: Change the specification of rotateL for non-finite Bits, or move rotations to FiniteBits

David Feuer david.feuer at gmail.com
Mon Sep 29 15:33:54 UTC 2014


The documentation currently specifies that for non-finite Bits instances,
rotate is the same as shift. This seems reasonable for Integer rotateR, but
very strange for Integer rotateL. In particular:

rotateL 5 (-1 :: Int) = -1
rotateL 5 (-1 :: Integer) = 16

Based on the concept that Integers represent two's complement out to
infinity, rotating a negative integer left should fill with 1s, but it
fills with 0s instead.


As stated in the subject, I think one reasonable solution is just to make
rotateL fill with 1s for negative non-finite instances, and the other is to
move rotations to FiniteBits, as was done with bitSize.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140929/892a383d/attachment-0001.html>

More information about the Libraries mailing list