packages feed

gray-extended 1.5.6 → 1.5.7

raw patch · 3 files changed

+8/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,7 @@ # Changelog for gray-extended +1.5.7 Simplified nix configuration.+ 1.5.6 Corrected copyright info.  1.5.5 Revamped to work with Nix + cabal-install
gray-extended.cabal view
@@ -1,7 +1,5 @@-cabal-version: 1.13- name:           gray-extended-version:        1.5.6+version:        1.5.7 synopsis:       Gray encoding schemes description:    Please see the README on GitHub at <https://github.com/mhwombat/gray-extended#readme> category:       Math@@ -16,6 +14,7 @@ extra-source-files:     README.md     ChangeLog.md+cabal-version: 1.13  source-repository head   type: git
src/Codec/Gray.hs view
@@ -25,6 +25,7 @@ import Data.List (foldl') import Data.Bits (Bits, shiftR, xor) +{-# INLINABLE grayCodes #-} -- | @'grayCodes' k@ generates the list of Binary Reflected Gray Code --   (BRGC) numbers of length k. This code is cyclic. grayCodes :: Int -> [[Bool]]@@ -32,12 +33,14 @@ grayCodes k =    let xs = grayCodes (k-1) in map (False:) xs ++ map (True:) (reverse xs) +{-# INLINABLE integralToGray #-} -- | @'integralToGray' n@ encodes @n@ using a BRGC, and returns the --   resulting bits as an integer. For example, encoding @17@ in BRGC --   results in @11001@, or 25. So @integralToGray 17@ returns @25@. integralToGray :: Bits a => a -> a integralToGray n = (n `shiftR` 1) `xor` n +{-# INLINABLE grayToIntegral #-} -- | @'grayToIntegral' n@ decodes @n@ using a BRGC, and returns the --   resulting integer. For example, 25 is @11001@, which is the code --   for 17. So @grayToIntegral 25@ returns @17@.@@ -46,6 +49,7 @@   where f k m | m /= 0     = f (k `xor` m) (m `shiftR` 1)               | otherwise = k   +{-# INLINABLE naryGrayCodes #-} -- | @'naryGrayCodes' xs k@ generates a non-Boolean (or n-ary) Gray code --   of length @k@ using the elements of @xs@ as \"digits\". This code --   is cyclic.