Sergey Astanin avatar Sergey Astanin committed 6051b51

update and add Num contexts to build on GHC 7.6

Comments (0)

Files changed (3)

Codec/Binary/Gray/Bits.hs

     , 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
 shiftR' n 0    = n
 shiftR' n s
   | isSigned n && signum n == -1 =
   | otherwise  = shiftR n s
 
 -- | 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,
 -- e.g. for 'Integer'.
-binary :: (Bits a) => a -> a
+binary :: (Bits a, Num a) => a -> a
 binary 0 = 0
 binary n =
   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

Codec/Binary/Gray/List.hs

 
 -- | 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, Num b) => b -> [Bool]
 toList 0 = []
 toList i
   | 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, Num 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, Num 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.
-Version:             0.2.1
+Version:             0.2.2
 
 -- 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.
-Homepage:            http://bitbucket.org/jetxee/hs-gray-code
+Homepage:            http://bitbucket.org/astanin/hs-gray-code
 
 -- The license under which the package is released.
 License:             BSD3
 Maintainer:          s.astanin@gmail.com
 
 -- A copyright notice.
--- Copyright:           
+-- Copyright:
 
 -- Stability of the pakcage (experimental, provisional, stable...)
 Stability:           Experimental
   -- Packages needed in order to build this package.
   Build-depends:
      base >= 3 && < 5
-  
+
   -- Modules not exported by this package.
   -- Other-modules:
-  
+
   -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
-  -- Build-tools:         
-  
+  -- Build-tools:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.