, 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) => 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) => 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) => 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) => a -> String
showBits = L.showBits . L.toList
-- | Convert a number to a list of bits in usual binary encoding (most
-- significant bit last). Truncates unset major bits.
-- This function is undefined for negative numbers of types that do not
-- have fixed bitsize, like 'Integer'.
-toList :: (Bits b) => b -> [Bool]
+toList :: (Bits b) => b -> [Bool]
| isSigned i && signum i == (-1) =
-- Like 'toList', but returns all unset major bits too. So the length
-- of the output is always the same length as @bitSize i@.
-toList' :: (Bits b) => b -> [Bool]
+toList' :: (Bits b) => b -> [Bool]
toList' i = map (testBit i) [0..bitSize i - 1]
-- | Convert a list of bits in binary encoding to a number.
-fromList :: (Bits b) => [Bool] -> b
+fromList :: (Bits b) => [Bool] -> b
fromList = sum . map fst . filter snd . zip (map (2^) [0..])
-- | Render a list of bits as a string of @0@s and @1@s.
-- The package version. See the Haskell package versioning policy
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
-- standards guiding when and how versions should be incremented.
-- A short (one-line) description of the package.
Synopsis: Gray code encoder/decoder.
@Bits@ is the default implementation.
-- URL for the project homepage or repository.
-- The license under which the package is released.
-- Stability of the pakcage (experimental, provisional, stable...)
-- Packages needed in order to build this package.
-- Modules not exported by this package.
-- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.