>>> unsafeShiftR 1 1000000 :: Int
1
This stays put because 1000000 `mod` 64 = 0, while
>>> shiftR 1 1000000 :: Int
0
saturates as you'd expect from:
>>> unsafeShiftL 1 1000000 :: Int
1
>>> shiftL 1 1000000 :: Int
0
That may be reasonable. I think it likely makes more sense than making the type of shift depend on the type of number, anyway.
On Jul 13, 2014 3:43 PM, "Henning Thielemann" <schlepptop@henning-thielemann.de> wrote:
Am 13.07.2014 20:36, schrieb David Feuer:
3. I would like to add explicit arithmetic and logical shifts to
Data.Bits. When fiddling bits, it's often easier to think about that
distinction explicitly, rather than in terms of whether the type is
signed or unsigned, and more convenient to have an explicit operation
rather than casting around.
What kind of data do you have in mind, where both signed and unsigned shifts make sense?
So far, I'd say, that calling "asr" on Word and "lsr" on Int should be a type error.
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries