, shiftL, shiftR, complement, xor, (.&.), (.|.), isSigned)

import qualified Codec.Binary.Gray.List as L

-- | Right shift without extension of the sign bit (reset it to zero).

-shiftR' :: (Bits a) => a -> Int -> a

+shiftR' :: (Bits a, Num a) => a -> Int -> a

| isSigned n && signum n == -1 =

-- | Convert an integer number from binary to Gray code.

-- 'gray' is undefined for negative numbers of types that do not have

-- fixed bitsize, e.g. for negative 'Integer's.

-gray :: (Bits a) => a -> a

+gray :: (Bits a, Num a) => a -> a

gray n = n `xor` (shiftR' n 1)

-- | Convert an integer number from Gray code to binary.

-- 'binary' is undefined for types that do not have fixed bitsize,

-binary :: (Bits a) => a -> a

+binary :: (Bits a, Num a) => a -> a

binary' mask0 n (copyMSB n)

-- | Render binary code as a string of @0@s and @1@s.

-- For example, @(42::Int8)@ is formatted as @101010@.

-showBits :: (Bits a) => a -> String

+showBits :: (Bits a, Num a) => a -> String

showBits = L.showBits . L.toList