largeword 1.2.1 → 1.2.2
raw patch · 3 files changed
+30/−9 lines, 3 filesdep ~largeword
Dependency ranges changed: largeword
Files
- Data/LargeWord.hs +21/−2
- Tests/Properties.hs +6/−4
- largeword.cabal +3/−3
Data/LargeWord.hs view
@@ -42,6 +42,23 @@ import Data.Binary (Binary, put, get) +#if MIN_VERSION_base(4,6,0) && !(MIN_VERSION_base(4,7,0))+class FiniteBits a where+ finiteBitSize :: a -> Int++instance FiniteBits Word8 where+ finiteBitSize = bitSize++instance FiniteBits Word16 where+ finiteBitSize = bitSize++instance FiniteBits Word32 where+ finiteBitSize = bitSize++instance FiniteBits Word64 where+ finiteBitSize = bitSize+#endif+ -- Keys have certain capabilities. class LargeWord a where@@ -208,7 +225,9 @@ "but ghc can't determine this" complement (LargeKey a b) = LargeKey (complement a) (complement b) bitSize = largeBitSize+#if MIN_VERSION_base(4,7,0) bitSizeMaybe = Just . largeBitSize+#endif isSigned _ = False #if MIN_VERSION_base(4,6,0) bit = bitDefault@@ -216,8 +235,8 @@ popCount = popCountDefault #endif -instance (LargeWord a, FiniteBits a, Ord a, Num a,- LargeWord b, FiniteBits b, Ord b, Num b) => FiniteBits (LargeKey a b) where+instance (LargeWord a, Bits a, FiniteBits a, Ord a, Num a,+ LargeWord b, Bits b, FiniteBits b, Ord b, Num b) => FiniteBits (LargeKey a b) where finiteBitSize = largeBitSize instance (Ord a, Bits a, FiniteBits a, Bounded a, Integral a, LargeWord a,
Tests/Properties.hs view
@@ -52,18 +52,20 @@ pRepeatedShift :: Int -> Property pRepeatedShift n =- (n >= 0) ==> (((iterate (`shift` 8) (1::Word192))!!n) == shift (1::Word192) (n*8))+ (n >= 0) && (n <= 1024) ==>+ (((iterate (`shift` 8) (1::Word192))!!n) == shift (1::Word192) (n*8)) pRepeatedShift' :: Int -> Property pRepeatedShift' n =- (n >= 0) ==> (((iterate (`shift` 8) a)!!n) == shift a (n*8))+ (n >= 0) && (n <= 1024) ==>+ (((iterate (`shift` 8) a)!!n) == shift a (n*8)) where a :: Word192 a = 0x0123456789ABCDEFFEDCBA98765432100011223344556677 - pRepeatedShift160 :: Int -> Property pRepeatedShift160 n =- (n >= 0) ==> (((iterate (`shift` 8) (1::Word160))!!n) == shift (1::Word160) (n*8))+ (n >= 0) && (n <= 1024) ==>+ (((iterate (`shift` 8) (1::Word160))!!n) == shift (1::Word160) (n*8)) u2 :: Assertion u2 = (2 :: LargeKey Word256 Word128) ^ 254 @?=
largeword.cabal view
@@ -1,5 +1,5 @@ name: largeword-version: 1.2.1+version: 1.2.2 license: BSD3 copyright: Dominic Steinitz <dominic@steinitz.org> author: Dominic Steinitz <dominic@steinitz.org>@@ -11,7 +11,7 @@ stability: stable build-type: Simple cabal-version: >= 1.9.2-tested-with: GHC == 7.0.3, GHC == 7.6.2+tested-with: GHC == 7.6.2, GHC == 7.8.2 -- Tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. Extra-source-files: Tests/Properties.hs@@ -37,7 +37,7 @@ test-framework-hunit >= 0.2.6 && < 0.4, QuickCheck >= 2.4.0.1, HUnit >= 1.2.2.3,- largeword == 1.2.1+ largeword == 1.2.2