Change Data.Bits.rotate to rotate Integer (unbounded) types
Peter Tanski
p.tanski at gmail.com
Tue Sep 19 16:08:01 EDT 2006
On Sep 19, 2006, at 3:28 PM, Neil Mitchell wrote:
> Hi,
>
>> Welcome back! Since Data.Bits is not defined in the Haskell 1998
>> standard, are we free to change the implementation of Data.Bits?
>
> No! If you do things like this, randomly changing the semantics of
> functions, people will come round to your house with burning pitch
> forks!
Or, if they reside across the Water, they might simply refuse to use
my program. The problem with Data.Bits.rotate, rotateL and rotateR
for Integers is redundancy: they are the same functions as shift,
shiftL and shiftR respectively. The unfortunate (and possibly buggy)
consequence for the unwary might be an unexpected change in the
operation of a function that uses rotate, rotateL or rotateR over
types in class Num when their Int32's have been promoted to Integers
to cover overflow. Otherwise it would be much easier to simply leave
it as is (for an array of doubles, where bitwise operations are
actually performed arithmetically, rotations would be difficult).
> If you want to have functions with new semantics, its probably a good
> idea to give them new names, or do something else to stop changing
> existing programs.
Certainly. The reason I asked about Data.Bits was that it is not
defined in the Haskell98 standard--I couldn't add IntegerRotate to
Prelude, and Data.Bits is a library. In any case, I think the
general response is that (a) specious idea or (b) already done in
other libraries.
-Pete
More information about the Glasgow-haskell-users
mailing list