
On 11/6/06, Bulat Ziganshin
Hello libraries,
fast shift operations that don't verify shift amount is rather popular demand. how about providing them in the Data.Bits?
-- |Shifts its first operand left by the amount of bits specified in -- second operand. Result of shifting by negative/too large amount -- is not specified. Should be used only in situations when you may -- guarantee correct value of second operand or don't care about result :) unsafeShiftL :: Int -> Int -> Int
unsafeShiftR :: Int -> Int -> Int
#ifdef __GLASGOW_HASKELL__ unsafeShiftL (I# a) (I# b) = (I# (a `iShiftL#` b)) unsafeShiftR (I# a) (I# b) = (I# (a `uncheckedIShiftRL#` b)) #else /* ! __GLASGOW_HASKELL__ */ unsafeShiftL = shiftL unsafeShiftR = shiftR #endif /* ! __GLASGOW_HASKELL__ */
it may be even better to include them in Bits class with obvious default definition
And use them for the default implementation of rotate, while we are at it.