-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Gray code encoder/decoder. -- -- Gray code is a binary numeral system where two successive numbers -- differ in only one bit. -- -- This package allows to convert numbers to one of the possible Gray -- codes and back. Two binary representations of a number are supported: -- [Bool] and types of Bits type class. Bits -- is the default implementation. @package gray-code @version 0.2 -- | Gray code is a binary numeral system where two successive numbers -- differ in only one bit. -- -- This module provides an interface to encode/decode numbers represented -- as lists of Bool. -- -- Algorithm: Haupt, R.L. and Haupt, S.E., Practical Genetic Algorithms, -- Second ed. (2004), 5.4. Gray Codes. module Codec.Binary.Gray.List -- | Take a list of bits (most significant last) in binary encoding and -- convert them to Gray code. gray :: [Bool] -> [Bool] -- | Take a list of bits in Gray code and convert them to binary encoding -- (most significant bit last). binary :: [Bool] -> [Bool] -- | Convert a number to a list of bits in usual binary encoding (most -- significant last). -- -- This function is undefined for negative numbers of types that do not -- have fixed bitsize, like Integer. toList :: Bits b => b -> [Bool] -- | Convert a list of bits in binary encoding to a number. fromList :: Bits b => [Bool] -> b -- | Render a list of bits as a string of 0s and 1s. showBits :: [Bool] -> String -- | Gray code is a binary numeral system where two successive numbers -- differ in only one bit. -- -- This module provides an interface to encode/decode -- Bits types. -- -- Algorithm: Haupt, R.L. and Haupt, S.E., Practical Genetic Algorithms, -- Second ed. (2004), 5.4. Gray Codes. module Codec.Binary.Gray.Bits -- | 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 Integers. gray :: Bits a => a -> a -- | Convert an integer number from Gray code to binary. -- -- binary is undefined for types that do not have fixed bitsize, -- e.g. for Integer. binary :: Bits a => a -> a -- | Render binary code as a string of 0s and 1s. For -- example, (42::Int8) is formatted as 101010. showBits :: Bits a => a -> String module Codec.Binary.Gray