module Data.Text.UnsafeShift
(
UnsafeShift(..)
) where
import qualified Data.Bits as Bits
import GHC.Base
import GHC.Word
class UnsafeShift a where
shiftL :: a -> Int -> a
shiftR :: a -> Int -> a
instance UnsafeShift Word16 where
shiftL (W16# x#) (I# i#) = W16# (x# `uncheckedShiftL#` i#)
shiftR (W16# x#) (I# i#) = W16# (x# `uncheckedShiftRL#` i#)
instance UnsafeShift Word32 where
shiftL (W32# x#) (I# i#) = W32# (x# `uncheckedShiftL#` i#)
shiftR (W32# x#) (I# i#) = W32# (x# `uncheckedShiftRL#` i#)
instance UnsafeShift Word64 where
shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
instance UnsafeShift Int where
shiftL (I# x#) (I# i#) = I# (x# `iShiftL#` i#)
shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)
instance UnsafeShift Integer where
shiftL = Bits.shiftL
shiftR = Bits.shiftR