packages feed

wide-word 0.1.9.0 → 0.2.0.0

raw patch · 16 files changed

+747/−127 lines, 16 filesdep ~QuickCheckPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,14 @@ # Revision history for wide-word +## 0.2.0.0 -- 2026-11-20++* Version number bump due significant changes to fromEnum behavior.+* Minor code changes and dependency bounds updates.+* Fix sign extension in fromIntegral rewrite rules from Int.+* Fix Enum instances for values outside the range of Int.+* Replace derived Ix instances with ones treating the value as a number.+* Fix Show instances for Int128 and Int256 to respect precedence.+ ## 0.1.9.0 -- 2026-01-21  * Add Int256 type contributed by Dmitry Kovalev.
src/Data/WideWord/Compat.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE StrictData #-} #if MIN_VERSION_base(4,17,0)@@ -27,7 +28,7 @@   ) where  #if MIN_VERSION_base(4,17,0)-import qualified GHC.Base+import GHC.Base qualified import GHC.Exts (Word64#, wordToWord64#, word64ToWord#, Int64#) #else import GHC.Base (Int#, Word#, quotRemWord2#, int2Word#, subWordC#, plusWord2#, or#, minusWord#,
src/Data/WideWord/Int128.hs view
@@ -6,6 +6,8 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_GHC -funbox-strict-fields #-}+-- See the comment on the rewrite rules for why this warning is disabled.+{-# OPTIONS_GHC -Wno-inline-rule-shadowing #-}  ----------------------------------------------------------------------------- ---- |@@ -34,8 +36,8 @@ import Control.DeepSeq (NFData (..))  import Data.Bits (Bits (..), FiniteBits (..), shiftL)-import Data.Data (Data, Typeable)-import Data.Ix (Ix)+import Data.Data (Data)+import Data.Ix (Ix (..)) #if ! MIN_VERSION_base(4,11,0) import Data.Semigroup ((<>)) #endif@@ -48,7 +50,7 @@ import Foreign.Storable (Storable (..))  import GHC.Base (Int (..))-import GHC.Enum (predError, succError)+import GHC.Enum (fromEnumError, predError, succError) import GHC.Exts ((+#), (*#), State#, Int#, Addr#, ByteArray#, MutableByteArray#) import GHC.Generics import GHC.Real ((%))@@ -71,7 +73,7 @@   { int128Hi64 :: !Word64   , int128Lo64 :: !Word64   }-  deriving (Eq, Data, Generic, Ix)+  deriving (Eq, Data, Generic)  instance Hashable Int128 where   hashWithSalt s (Int128 a1 a2) = s `hashWithSalt` a1 `hashWithSalt` a2@@ -93,7 +95,7 @@     zeros = replicate (16 - length h0) '0'  instance Show Int128 where-  show = show . toInteger+  showsPrec p = showsPrec p . toInteger  instance Read Int128 where   readsPrec p s = [(fromInteger128 (x :: Integer), r) | (x, r) <- readsPrec p s]@@ -105,11 +107,25 @@   minBound = Int128 0x8000000000000000 0   maxBound = Int128 0x7fffffffffffffff maxBound +-- A derived instance would treat each 64 bit word as a separate dimension+-- rather than treating the value as a single number.+instance Ix Int128 where+  range (a, b) = enumFromTo128 a b+  index b@(a, _) i+    | inRange b i = toInt (i - a)+    | otherwise =+        error ("Ix{Int128}.index: Index (" ++ show i ++ ") out of range (" ++ show b ++ ")")+  inRange (a, b) i = a <= i && i <= b+ instance Enum Int128 where   succ = succ128   pred = pred128   toEnum = toEnum128   fromEnum = fromEnum128+  enumFrom x = enumFromTo128 x maxBound+  enumFromThen x y = enumFromThenTo128 x y (if y >= x then maxBound else minBound)+  enumFromTo = enumFromTo128+  enumFromThenTo = enumFromThenTo128  instance Num Int128 where   (+) = plus128@@ -194,6 +210,21 @@  -- ----------------------------------------------------------------------------- -- Rewrite rules.+--+-- These rules let `fromIntegral` between `Int128` and the standard fixed width+-- types skip the default `fromInteger . toInteger` round trip via `Integer`.+--+-- In recent versions of base, `fromIntegral` has an INLINE pragma without a+-- phase, so GHC may inline it before these rules get a chance to match (for+-- example inside a polymorphic function that is only later specialised to+-- `Int128`). GHC reports this with -Winline-rule-shadowing. Its suggested fix,+-- adding a phase to the INLINE pragma, can only be made to `fromIntegral` in+-- base itself, so that warning is disabled for this module instead.+--+-- Since whether or not a rule fires depends on the context, every rule MUST+-- give exactly the same result as `fromInteger . toInteger`. The rules are an+-- optimisation only. In particular, conversion from `Int` must sign extend.+-- The `prop_fromIntegral_rules` test checks this.  {-# RULES "fromIntegral :: Int -> Int128"     fromIntegral = fromInt@@ -209,7 +240,7 @@  {-# INLINE fromInt #-} fromInt :: Int -> Int128-fromInt = Int128 0 . fromIntegral+fromInt i = Int128 (if i < 0 then maxBound else 0) (fromIntegral i)  {-# INLINE fromWord #-} fromWord :: Word -> Int128@@ -267,11 +298,28 @@  {-# INLINABLE toEnum128 #-} toEnum128 :: Int -> Int128-toEnum128 i = Int128 0 (toEnum i)+toEnum128 = fromInt  {-# INLINABLE fromEnum128 #-} fromEnum128 :: Int128 -> Int-fromEnum128 (Int128 _ a0) = fromEnum a0+fromEnum128 x+  | x < fromInt minBound || x > fromInt maxBound = fromEnumError "Int128" x+  | otherwise = toInt x++{-# INLINABLE enumFromTo128 #-}+enumFromTo128 :: Int128 -> Int128 -> [Int128]+enumFromTo128 x y+  | x > y = []+  | otherwise = go x+  where+    -- Stop at `y` before incrementing so that `y == maxBound` does not overflow.+    go i = i : if i == y then [] else go (i + 1)++-- Go via `Integer` to avoid having to deal with overflow at either bound.+{-# INLINABLE enumFromThenTo128 #-}+enumFromThenTo128 :: Int128 -> Int128 -> Int128 -> [Int128]+enumFromThenTo128 x1 x2 y =+  map fromInteger128 [toInteger128 x1, toInteger128 x2 .. toInteger128 y]  -- ----------------------------------------------------------------------------- -- Functions for `Num` instance.
src/Data/WideWord/Int256.hs view
@@ -6,6 +6,8 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_GHC -funbox-strict-fields #-}+-- See the comment on the rewrite rules for why this warning is disabled.+{-# OPTIONS_GHC -Wno-inline-rule-shadowing #-}  #include <MachDeps.h> @@ -20,7 +22,7 @@  import Data.Bits (Bits (..), FiniteBits (..), shiftL) import Data.Data (Data)-import Data.Ix (Ix)+import Data.Ix (Ix (..)) #if ! MIN_VERSION_base(4,11,0) import Data.Semigroup ((<>)) #endif@@ -32,7 +34,7 @@ import Foreign.Storable (Storable (..))  import GHC.Base (Int (..))-import GHC.Enum (predError, succError)+import GHC.Enum (fromEnumError, predError, succError) import GHC.Exts ((*#), (+#), Int#, State#, Addr#, ByteArray#, MutableByteArray#) import GHC.Generics import GHC.Real ((%))@@ -52,7 +54,7 @@   , int256m0 :: !Word64   , int256lo :: !Word64   }-  deriving (Eq, Data, Generic, Ix)+  deriving (Eq, Data, Generic)  instance Hashable Int256 where   hashWithSalt s (Int256 a1 a2 a3 a4) =@@ -86,7 +88,7 @@     zeros2 = replicate (16 - length h2) '0'  instance Show Int256 where-  show = show . toInteger+  showsPrec p = showsPrec p . toInteger  instance Read Int256 where   readsPrec p s = [(fromInteger256 (x :: Integer), r) | (x, r) <- readsPrec p s]@@ -98,11 +100,25 @@   minBound = Int256 0x8000000000000000 0 0 0   maxBound = Int256 0x7fffffffffffffff maxBound maxBound maxBound +-- A derived instance would treat each 64 bit word as a separate dimension+-- rather than treating the value as a single number.+instance Ix Int256 where+  range (a, b) = enumFromTo256 a b+  index b@(a, _) i+    | inRange b i = toInt (i - a)+    | otherwise =+        error ("Ix{Int256}.index: Index (" ++ show i ++ ") out of range (" ++ show b ++ ")")+  inRange (a, b) i = a <= i && i <= b+ instance Enum Int256 where   succ = succ256   pred = pred256   toEnum = toEnum256   fromEnum = fromEnum256+  enumFrom x = enumFromTo256 x maxBound+  enumFromThen x y = enumFromThenTo256 x y (if y >= x then maxBound else minBound)+  enumFromTo = enumFromTo256+  enumFromThenTo = enumFromThenTo256  instance Num Int256 where   (+) = plus256@@ -188,6 +204,21 @@  -- ----------------------------------------------------------------------------- -- Rewrite rules.+--+-- These rules let `fromIntegral` between `Int256` and the standard fixed width+-- types skip the default `fromInteger . toInteger` round trip via `Integer`.+--+-- In recent versions of base, `fromIntegral` has an INLINE pragma without a+-- phase, so GHC may inline it before these rules get a chance to match (for+-- example inside a polymorphic function that is only later specialised to+-- `Int256`). GHC reports this with -Winline-rule-shadowing. Its suggested fix,+-- adding a phase to the INLINE pragma, can only be made to `fromIntegral` in+-- base itself, so that warning is disabled for this module instead.+--+-- Since whether or not a rule fires depends on the context, every rule MUST+-- give exactly the same result as `fromInteger . toInteger`. The rules are an+-- optimisation only. In particular, conversion from `Int` must sign extend.+-- The `prop_fromIntegral_rules` test checks this.  {-# RULES "fromIntegral :: Int -> Int256"     fromIntegral = fromInt@@ -203,7 +234,9 @@  {-# INLINE fromInt #-} fromInt :: Int -> Int256-fromInt = Int256 0 0 0 . fromIntegral+fromInt i = Int256 hi hi hi (fromIntegral i)+  where+    hi = if i < 0 then maxBound else 0  {-# INLINE fromWord #-} fromWord :: Word -> Int256@@ -270,11 +303,28 @@  {-# INLINABLE toEnum256 #-} toEnum256 :: Int -> Int256-toEnum256 i = Int256 0 0 0 (toEnum i)+toEnum256 = fromInt  {-# INLINABLE fromEnum256 #-} fromEnum256 :: Int256 -> Int-fromEnum256 (Int256 _ _ _ a0) = fromEnum a0+fromEnum256 x+  | x < fromInt minBound || x > fromInt maxBound = fromEnumError "Int256" x+  | otherwise = toInt x++{-# INLINABLE enumFromTo256 #-}+enumFromTo256 :: Int256 -> Int256 -> [Int256]+enumFromTo256 x y+  | x > y = []+  | otherwise = go x+  where+    -- Stop at `y` before incrementing so that `y == maxBound` does not overflow.+    go i = i : if i == y then [] else go (i + 1)++-- Go via `Integer` to avoid having to deal with overflow at either bound.+{-# INLINABLE enumFromThenTo256 #-}+enumFromThenTo256 :: Int256 -> Int256 -> Int256 -> [Int256]+enumFromThenTo256 x1 x2 y =+  map fromInteger256 [toInteger256 x1, toInteger256 x2 .. toInteger256 y]  -- ----------------------------------------------------------------------------- -- Functions for `Num` instance.
src/Data/WideWord/Word128.hs view
@@ -2,10 +2,13 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_GHC -funbox-strict-fields #-}+-- See the comment on the rewrite rules for why this warning is disabled.+{-# OPTIONS_GHC -Wno-inline-rule-shadowing #-}  ----------------------------------------------------------------------------- ---- |@@ -35,7 +38,7 @@  import Data.Bits (Bits (..), FiniteBits (..), shiftL) import Data.Data (Data)-import Data.Ix (Ix)+import Data.Ix (Ix (..)) #if ! MIN_VERSION_base(4,11,0) import Data.Semigroup ((<>)) #endif@@ -45,7 +48,7 @@ import Foreign.Storable (Storable (..))  import GHC.Base (Int (..))-import GHC.Enum (predError, succError)+import GHC.Enum (fromEnumError, predError, succError, toEnumError) import GHC.Exts ((*#), (+#), Int#, State#, ByteArray#, MutableByteArray#, Addr#) import GHC.Generics (Generic) import GHC.Real ((%), divZeroError)@@ -62,7 +65,7 @@   { word128Hi64 :: !Word64   , word128Lo64 :: !Word64   }-  deriving (Eq, Data, Generic, Ix)+  deriving (Eq, Data, Generic)  instance Hashable Word128 where   hashWithSalt s (Word128 a1 a2) = s `hashWithSalt` a1 `hashWithSalt` a2@@ -96,11 +99,25 @@   minBound = zeroWord128   maxBound = Word128 maxBound maxBound +-- A derived instance would treat each 64 bit word as a separate dimension+-- rather than treating the value as a single number.+instance Ix Word128 where+  range (a, b) = enumFromTo128 a b+  index b@(a, _) i+    | inRange b i = toInt (i - a)+    | otherwise =+        error ("Ix{Word128}.index: Index (" ++ show i ++ ") out of range (" ++ show b ++ ")")+  inRange (a, b) i = a <= i && i <= b+ instance Enum Word128 where   succ = succ128   pred = pred128   toEnum = toEnum128   fromEnum = fromEnum128+  enumFrom x = enumFromTo128 x maxBound+  enumFromThen x y = enumFromThenTo128 x y (if y >= x then maxBound else minBound)+  enumFromTo = enumFromTo128+  enumFromThenTo = enumFromThenTo128  instance Num Word128 where   (+) = plus128@@ -186,6 +203,21 @@  -- ----------------------------------------------------------------------------- -- Rewrite rules.+--+-- These rules let `fromIntegral` between `Word128` and the standard fixed width+-- types skip the default `fromInteger . toInteger` round trip via `Integer`.+--+-- In recent versions of base, `fromIntegral` has an INLINE pragma without a+-- phase, so GHC may inline it before these rules get a chance to match (for+-- example inside a polymorphic function that is only later specialised to+-- `Word128`). GHC reports this with -Winline-rule-shadowing. Its suggested fix,+-- adding a phase to the INLINE pragma, can only be made to `fromIntegral` in+-- base itself, so that warning is disabled for this module instead.+--+-- Since whether or not a rule fires depends on the context, every rule MUST+-- give exactly the same result as `fromInteger . toInteger`. The rules are an+-- optimisation only. In particular, conversion from `Int` must sign extend.+-- The `prop_fromIntegral_rules` test checks this.  {-# RULES "fromIntegral :: Word128 -> Word128" fromIntegral = id :: Word128 -> Word128@@ -203,7 +235,7 @@  {-# INLINE fromInt #-} fromInt :: Int -> Word128-fromInt = Word128 0 . fromIntegral+fromInt i = Word128 (if i < 0 then maxBound else 0) (fromIntegral i)  {-# INLINE fromWord #-} fromWord :: Word -> Word128@@ -253,11 +285,30 @@  {-# INLINABLE toEnum128 #-} toEnum128 :: Int -> Word128-toEnum128 i = Word128 0 (toEnum i)+toEnum128 i+  | i < 0 = toEnumError "Word128" i (minBound :: Word128, maxBound :: Word128)+  | otherwise = fromInt i  {-# INLINABLE fromEnum128 #-} fromEnum128 :: Word128 -> Int-fromEnum128 (Word128 _ a0) = fromEnum a0+fromEnum128 x+  | x > fromInt maxBound = fromEnumError "Word128" x+  | otherwise = toInt x++{-# INLINABLE enumFromTo128 #-}+enumFromTo128 :: Word128 -> Word128 -> [Word128]+enumFromTo128 x y+  | x > y = []+  | otherwise = go x+  where+    -- Stop at `y` before incrementing so that `y == maxBound` does not overflow.+    go i = i : if i == y then [] else go (i + 1)++-- Go via `Integer` to avoid having to deal with overflow at either bound.+{-# INLINABLE enumFromThenTo128 #-}+enumFromThenTo128 :: Word128 -> Word128 -> Word128 -> [Word128]+enumFromThenTo128 x1 x2 y =+  map fromInteger128 [toInteger128 x1, toInteger128 x2 .. toInteger128 y]  -- ----------------------------------------------------------------------------- -- Functions for `Num` instance.
src/Data/WideWord/Word256.hs view
@@ -2,10 +2,13 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_GHC -funbox-strict-fields #-}+-- See the comment on the rewrite rules for why this warning is disabled.+{-# OPTIONS_GHC -Wno-inline-rule-shadowing #-}  ----------------------------------------------------------------------------- ---- |@@ -34,7 +37,7 @@  import Data.Bits (Bits (..), FiniteBits (..), shiftL) import Data.Data (Data)-import Data.Ix (Ix)+import Data.Ix (Ix (..)) #if ! MIN_VERSION_base(4,11,0) import Data.Semigroup ((<>)) #endif@@ -43,7 +46,7 @@ import Foreign.Storable (Storable (..))  import GHC.Base (Int (..))-import GHC.Enum (predError, succError)+import GHC.Enum (fromEnumError, predError, succError, toEnumError) import GHC.Exts ((*#), (+#), Int#, State#, ByteArray#, MutableByteArray#, Addr#) import GHC.Generics (Generic) import GHC.Real ((%))@@ -65,7 +68,7 @@   , word256m0 :: !Word64   , word256lo :: !Word64   }-  deriving (Eq, Data, Generic, Ix)+  deriving (Eq, Data, Generic)  instance Hashable Word256 where   hashWithSalt s (Word256 a1 a2 a3 a4) =@@ -108,11 +111,25 @@   minBound = zeroWord256   maxBound = Word256 maxBound maxBound maxBound maxBound +-- A derived instance would treat each 64 bit word as a separate dimension+-- rather than treating the value as a single number.+instance Ix Word256 where+  range (a, b) = enumFromTo256 a b+  index b@(a, _) i+    | inRange b i = toInt (i - a)+    | otherwise =+        error ("Ix{Word256}.index: Index (" ++ show i ++ ") out of range (" ++ show b ++ ")")+  inRange (a, b) i = a <= i && i <= b+ instance Enum Word256 where   succ = succ256   pred = pred256   toEnum = toEnum256   fromEnum = fromEnum256+  enumFrom x = enumFromTo256 x maxBound+  enumFromThen x y = enumFromThenTo256 x y (if y >= x then maxBound else minBound)+  enumFromTo = enumFromTo256+  enumFromThenTo = enumFromThenTo256  instance Num Word256 where   (+) = plus256@@ -198,6 +215,21 @@  -- ----------------------------------------------------------------------------- -- Rewrite rules.+--+-- These rules let `fromIntegral` between `Word256` and the standard fixed width+-- types skip the default `fromInteger . toInteger` round trip via `Integer`.+--+-- In recent versions of base, `fromIntegral` has an INLINE pragma without a+-- phase, so GHC may inline it before these rules get a chance to match (for+-- example inside a polymorphic function that is only later specialised to+-- `Word256`). GHC reports this with -Winline-rule-shadowing. Its suggested fix,+-- adding a phase to the INLINE pragma, can only be made to `fromIntegral` in+-- base itself, so that warning is disabled for this module instead.+--+-- Since whether or not a rule fires depends on the context, every rule MUST+-- give exactly the same result as `fromInteger . toInteger`. The rules are an+-- optimisation only. In particular, conversion from `Int` must sign extend.+-- The `prop_fromIntegral_rules` test checks this.  {-# RULES "fromIntegral :: Word256 -> Word256" fromIntegral = id :: Word256 -> Word256@@ -215,7 +247,9 @@  {-# INLINE fromInt #-} fromInt :: Int -> Word256-fromInt = Word256 0 0 0 . fromIntegral+fromInt i = Word256 hi hi hi (fromIntegral i)+  where+    hi = if i < 0 then maxBound else 0  {-# INLINE fromWord #-} fromWord :: Word -> Word256@@ -275,11 +309,30 @@  {-# INLINABLE toEnum256 #-} toEnum256 :: Int -> Word256-toEnum256 i = Word256 0 0 0 (toEnum i)+toEnum256 i+  | i < 0 = toEnumError "Word256" i (minBound :: Word256, maxBound :: Word256)+  | otherwise = fromInt i  {-# INLINABLE fromEnum256 #-} fromEnum256 :: Word256 -> Int-fromEnum256 (Word256 _ _ _ a0) = fromEnum a0+fromEnum256 x+  | x > fromInt maxBound = fromEnumError "Word256" x+  | otherwise = toInt x++{-# INLINABLE enumFromTo256 #-}+enumFromTo256 :: Word256 -> Word256 -> [Word256]+enumFromTo256 x y+  | x > y = []+  | otherwise = go x+  where+    -- Stop at `y` before incrementing so that `y == maxBound` does not overflow.+    go i = i : if i == y then [] else go (i + 1)++-- Go via `Integer` to avoid having to deal with overflow at either bound.+{-# INLINABLE enumFromThenTo256 #-}+enumFromThenTo256 :: Word256 -> Word256 -> Word256 -> [Word256]+enumFromThenTo256 x1 x2 y =+  map fromInteger256 [toInteger256 x1, toInteger256 x2 .. toInteger256 y]  -- ----------------------------------------------------------------------------- -- Functions for `Num` instance.
test/Test/Data/WideWord/Gen.hs view
@@ -1,11 +1,12 @@+{-# LANGUAGE ImportQualifiedPost #-} module Test.Data.WideWord.Gen where -import           Data.WideWord-import           Data.Word (Word32, Word64)+import Data.WideWord+import Data.Word (Word32, Word64) -import           Hedgehog (Gen)-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Gen)+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range   genInt128 :: Gen Int128
test/Test/Data/WideWord/Int128.hs view
@@ -1,29 +1,31 @@+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE TemplateHaskell #-} module Test.Data.WideWord.Int128   ( tests   ) where -import           Control.Exception (SomeException, evaluate, try)-import           Control.Monad (unless)-import           Control.Monad.IO.Class (liftIO)+import Control.Exception (SomeException, evaluate, try)+import Control.Monad (unless)+import Control.Monad.IO.Class (liftIO) -import           Data.Bifunctor (first)-import qualified Data.Binary as Binary-import           Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros+import Data.Bifunctor (first)+import Data.Binary qualified as Binary+import Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros                             , popCount, rotateL, rotateR, shiftL, shiftR, testBit, xor)-import           Data.Int (Int32)-import           Data.Primitive.PrimArray-import           Data.Primitive.Ptr-import           Data.Word (Word8, Word64, byteSwap64)-import           Data.WideWord+import Data.Ix (inRange, index, range, rangeSize)+import Data.Int (Int32)+import Data.Primitive.PrimArray+import Data.Primitive.Ptr+import Data.Word (Word8, Word64, byteSwap64)+import Data.WideWord -import           Foreign (allocaBytes)-import           Foreign.Storable (Storable (..))+import Foreign (allocaBytes)+import Foreign.Storable (Storable (..)) -import           Hedgehog (Property, (===), discover)-import qualified Hedgehog as H-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Property, (===), discover)+import Hedgehog qualified as H+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range  import Test.Data.WideWord.Gen @@ -141,6 +143,104 @@   propertyCount $ do     i128 <- H.forAll genInt128     toInteger128 (signum i128) === signum (toInteger128 i128)++prop_enumFromTo :: Property+prop_enumFromTo =+  propertyCount $ do+    a <- H.forAll genInt128+    n <- H.forAll $ Gen.int (Range.linear 0 20)+    let b = a + fromIntegral n+    map toInteger [a .. b] === [toInteger a .. toInteger b]++prop_enumFromThenTo :: Property+prop_enumFromThenTo =+  propertyCount $ do+    a <- H.forAll genInt128+    step <- H.forAll $ Gen.filter (/= 0) (Gen.int (Range.linearFrom 0 (-5) 5))+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    let b = a + fromIntegral step+        c = a + fromIntegral (step * n)+    map toInteger [a, b .. c] === [toInteger a, toInteger b .. toInteger c]++prop_enumFrom_enumFromThen_bounds :: Property+prop_enumFrom_enumFromThen_bounds =+  propertyCount $ do+    n <- H.forAll $ Gen.int (Range.linear 1 10)+    let top = maxBound - fromIntegral n :: Int128+        bottom = minBound + fromIntegral n :: Int128+    map toInteger [top ..] === [toInteger top .. toInteger (maxBound :: Int128)]+    map toInteger [top, top + 1 ..] === [toInteger top .. toInteger (maxBound :: Int128)]+    map toInteger [bottom, bottom - 1 ..]+      === [toInteger bottom, toInteger bottom - 1 .. toInteger (minBound :: Int128)]++prop_toEnum_Int :: Property+prop_toEnum_Int =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    r <- liftIO $ tryMaybe (toEnum i :: Int128)+    r === if True || i >= 0 then Just (fromInteger (toInteger i)) else Nothing+    case r of+      Just x -> fromEnum x === i+      Nothing -> pure ()++prop_fromEnum_range :: Property+prop_fromEnum_range =+  propertyCount $ do+    x <- H.forAll $ Gen.choice [genInt128, fromInteger . toInteger <$> Gen.int Range.constantBounded]+    let xi = toInteger x+    r <- liftIO $ tryMaybe (fromEnum x)+    r === if xi >= toInteger (minBound :: Int) && xi <= toInteger (maxBound :: Int)+            then Just (fromInteger xi)+            else Nothing++prop_ix :: Property+prop_ix =+  propertyCount $ do+    a <- H.forAll genInt128+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    k <- H.forAll $ Gen.int (Range.linear (-2) 12)+    let b = a + fromIntegral n+        x = a + fromIntegral k+        bi = (toInteger a, toInteger b)+    map toInteger (range (a, b)) === range bi+    inRange (a, b) x === inRange bi (toInteger x)+    rangeSize (a, b) === rangeSize bi+    r <- liftIO $ tryMaybe (index (a, b) x)+    r === if inRange bi (toInteger x) then Just (index bi (toInteger x)) else Nothing++prop_showsPrec :: Property+prop_showsPrec =+  propertyCount $ do+    x <- H.forAll genInt128+    showsPrec 11 x "" === showsPrec 11 (toInteger x) ""+    read (show (Just x)) === Just x++-- Evaluate a value, returning `Nothing` if that throws an exception.+tryMaybe :: a -> IO (Maybe a)+tryMaybe x =+  either discard Just <$> try (evaluate x)+  where+    discard :: SomeException -> Maybe b+    discard _ = Nothing++-- Each `fromIntegral` here may be rewritten by one of the library's RULES, and+-- those must agree with the `fromInteger . toInteger` definition.+prop_fromIntegral_rules :: Property+prop_fromIntegral_rules =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    w <- H.forAll $ Gen.word Range.constantBounded+    w32 <- H.forAll $ Gen.word32 Range.constantBounded+    w64 <- H.forAll genWord64+    x <- H.forAll genInt128+    (fromIntegral i :: Int128) === fromInteger (toInteger i)+    (fromIntegral w :: Int128) === fromInteger (toInteger w)+    (fromIntegral w32 :: Int128) === fromInteger (toInteger w32)+    (fromIntegral w64 :: Int128) === fromInteger (toInteger w64)+    (fromIntegral x :: Int) === fromInteger (toInteger x)+    (fromIntegral x :: Word) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w32) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w64) === fromInteger (toInteger x)  prop_fromInteger :: Property prop_fromInteger =
test/Test/Data/WideWord/Int256.hs view
@@ -1,27 +1,30 @@+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE TemplateHaskell #-} module Test.Data.WideWord.Int256   ( tests   ) where -import           Control.Monad.IO.Class (liftIO)-import           Control.Monad (unless)+import Control.Exception (SomeException, evaluate, try)+import Control.Monad.IO.Class (liftIO)+import Control.Monad (unless) -import qualified Data.Binary as Binary-import           Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros+import Data.Binary qualified as Binary+import Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros                             , popCount, rotateL, rotateR, shiftL, shiftR, testBit, xor)-import           Data.Int (Int32)-import           Data.Primitive.PrimArray-import           Data.Primitive.Ptr-import           Data.Word (Word64, Word8)-import           Data.WideWord+import Data.Ix (inRange, index, range, rangeSize)+import Data.Int (Int32)+import Data.Primitive.PrimArray+import Data.Primitive.Ptr+import Data.Word (Word64, Word8)+import Data.WideWord -import           Foreign (allocaBytes)-import           Foreign.Storable (Storable (..))+import Foreign (allocaBytes)+import Foreign.Storable (Storable (..)) -import           Hedgehog (Property, (===), discover)-import qualified Hedgehog as H-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Property, (===), discover)+import Hedgehog qualified as H+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range  import Test.Data.WideWord.Gen @@ -138,6 +141,104 @@   propertyCount $ do     i256 <- H.forAll genInt256     toInteger256 (signum i256) === signum (toInteger256 i256)++prop_enumFromTo :: Property+prop_enumFromTo =+  propertyCount $ do+    a <- H.forAll genInt256+    n <- H.forAll $ Gen.int (Range.linear 0 20)+    let b = a + fromIntegral n+    map toInteger [a .. b] === [toInteger a .. toInteger b]++prop_enumFromThenTo :: Property+prop_enumFromThenTo =+  propertyCount $ do+    a <- H.forAll genInt256+    step <- H.forAll $ Gen.filter (/= 0) (Gen.int (Range.linearFrom 0 (-5) 5))+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    let b = a + fromIntegral step+        c = a + fromIntegral (step * n)+    map toInteger [a, b .. c] === [toInteger a, toInteger b .. toInteger c]++prop_enumFrom_enumFromThen_bounds :: Property+prop_enumFrom_enumFromThen_bounds =+  propertyCount $ do+    n <- H.forAll $ Gen.int (Range.linear 1 10)+    let top = maxBound - fromIntegral n :: Int256+        bottom = minBound + fromIntegral n :: Int256+    map toInteger [top ..] === [toInteger top .. toInteger (maxBound :: Int256)]+    map toInteger [top, top + 1 ..] === [toInteger top .. toInteger (maxBound :: Int256)]+    map toInteger [bottom, bottom - 1 ..]+      === [toInteger bottom, toInteger bottom - 1 .. toInteger (minBound :: Int256)]++prop_toEnum_Int :: Property+prop_toEnum_Int =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    r <- liftIO $ tryMaybe (toEnum i :: Int256)+    r === if True || i >= 0 then Just (fromInteger (toInteger i)) else Nothing+    case r of+      Just x -> fromEnum x === i+      Nothing -> pure ()++prop_fromEnum_range :: Property+prop_fromEnum_range =+  propertyCount $ do+    x <- H.forAll $ Gen.choice [genInt256, fromInteger . toInteger <$> Gen.int Range.constantBounded]+    let xi = toInteger x+    r <- liftIO $ tryMaybe (fromEnum x)+    r === if xi >= toInteger (minBound :: Int) && xi <= toInteger (maxBound :: Int)+            then Just (fromInteger xi)+            else Nothing++prop_ix :: Property+prop_ix =+  propertyCount $ do+    a <- H.forAll genInt256+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    k <- H.forAll $ Gen.int (Range.linear (-2) 12)+    let b = a + fromIntegral n+        x = a + fromIntegral k+        bi = (toInteger a, toInteger b)+    map toInteger (range (a, b)) === range bi+    inRange (a, b) x === inRange bi (toInteger x)+    rangeSize (a, b) === rangeSize bi+    r <- liftIO $ tryMaybe (index (a, b) x)+    r === if inRange bi (toInteger x) then Just (index bi (toInteger x)) else Nothing++prop_showsPrec :: Property+prop_showsPrec =+  propertyCount $ do+    x <- H.forAll genInt256+    showsPrec 11 x "" === showsPrec 11 (toInteger x) ""+    read (show (Just x)) === Just x++-- Evaluate a value, returning `Nothing` if that throws an exception.+tryMaybe :: a -> IO (Maybe a)+tryMaybe x =+  either discard Just <$> try (evaluate x)+  where+    discard :: SomeException -> Maybe b+    discard _ = Nothing++-- Each `fromIntegral` here may be rewritten by one of the library's RULES, and+-- those must agree with the `fromInteger . toInteger` definition.+prop_fromIntegral_rules :: Property+prop_fromIntegral_rules =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    w <- H.forAll $ Gen.word Range.constantBounded+    w32 <- H.forAll $ Gen.word32 Range.constantBounded+    w64 <- H.forAll genWord64+    x <- H.forAll genInt256+    (fromIntegral i :: Int256) === fromInteger (toInteger i)+    (fromIntegral w :: Int256) === fromInteger (toInteger w)+    (fromIntegral w32 :: Int256) === fromInteger (toInteger w32)+    (fromIntegral w64 :: Int256) === fromInteger (toInteger w64)+    (fromIntegral x :: Int) === fromInteger (toInteger x)+    (fromIntegral x :: Word) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w32) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w64) === fromInteger (toInteger x)  prop_fromInteger :: Property prop_fromInteger =
test/Test/Data/WideWord/Word128.hs view
@@ -1,30 +1,33 @@+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE TemplateHaskell #-} module Test.Data.WideWord.Word128   ( tests   ) where -import           Control.Monad.IO.Class (liftIO)-import           Control.Monad (unless)+import Control.Exception (SomeException, evaluate, try)+import Control.Monad.IO.Class (liftIO)+import Control.Monad (unless) -import qualified Data.Binary as Binary-import           Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros+import Data.Binary qualified as Binary+import Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros                             , popCount, rotateL, rotateR, shiftL, shiftR, testBit, xor)-import           Data.Int (Int32)-import           Data.Primitive.PrimArray (primArrayFromList, primArrayToList, readPrimArray,+import Data.Ix (inRange, index, range, rangeSize)+import Data.Int (Int32)+import Data.Primitive.PrimArray (primArrayFromList, primArrayToList, readPrimArray,                    setPrimArray, unsafeFreezePrimArray, unsafeThawPrimArray, writePrimArray)-import           Data.Primitive.Ptr (readOffPtr, writeOffPtr)-import           Data.Word (Word8, Word64, byteSwap64)-import           Data.WideWord+import Data.Primitive.Ptr (readOffPtr, writeOffPtr)+import Data.Word (Word8, Word64, byteSwap64)+import Data.WideWord -import           Foreign (allocaBytes)-import           Foreign.Storable (Storable (..))+import Foreign (allocaBytes)+import Foreign.Storable (Storable (..)) -import           Hedgehog (Property, (===), discover)-import qualified Hedgehog as H-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Property, (===), discover)+import Hedgehog qualified as H+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range -import           Test.Data.WideWord.Gen+import Test.Data.WideWord.Gen   -- Set the number of times to run each property test here.@@ -139,6 +142,104 @@   propertyCount $ do     w128 <- H.forAll genWord128     toInteger128 (signum w128) === signum (toInteger128 w128)++prop_enumFromTo :: Property+prop_enumFromTo =+  propertyCount $ do+    a <- H.forAll genWord128+    n <- H.forAll $ Gen.int (Range.linear 0 20)+    let b = a + fromIntegral n+    map toInteger [a .. b] === [toInteger a .. toInteger b]++prop_enumFromThenTo :: Property+prop_enumFromThenTo =+  propertyCount $ do+    a <- H.forAll genWord128+    step <- H.forAll $ Gen.filter (/= 0) (Gen.int (Range.linearFrom 0 (-5) 5))+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    let b = a + fromIntegral step+        c = a + fromIntegral (step * n)+    map toInteger [a, b .. c] === [toInteger a, toInteger b .. toInteger c]++prop_enumFrom_enumFromThen_bounds :: Property+prop_enumFrom_enumFromThen_bounds =+  propertyCount $ do+    n <- H.forAll $ Gen.int (Range.linear 1 10)+    let top = maxBound - fromIntegral n :: Word128+        bottom = minBound + fromIntegral n :: Word128+    map toInteger [top ..] === [toInteger top .. toInteger (maxBound :: Word128)]+    map toInteger [top, top + 1 ..] === [toInteger top .. toInteger (maxBound :: Word128)]+    map toInteger [bottom, bottom - 1 ..]+      === [toInteger bottom, toInteger bottom - 1 .. toInteger (minBound :: Word128)]++prop_toEnum_Int :: Property+prop_toEnum_Int =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    r <- liftIO $ tryMaybe (toEnum i :: Word128)+    r === if False || i >= 0 then Just (fromInteger (toInteger i)) else Nothing+    case r of+      Just x -> fromEnum x === i+      Nothing -> pure ()++prop_fromEnum_range :: Property+prop_fromEnum_range =+  propertyCount $ do+    x <- H.forAll $ Gen.choice [genWord128, fromInteger . toInteger <$> Gen.int Range.constantBounded]+    let xi = toInteger x+    r <- liftIO $ tryMaybe (fromEnum x)+    r === if xi >= toInteger (minBound :: Int) && xi <= toInteger (maxBound :: Int)+            then Just (fromInteger xi)+            else Nothing++prop_ix :: Property+prop_ix =+  propertyCount $ do+    a <- H.forAll genWord128+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    k <- H.forAll $ Gen.int (Range.linear (-2) 12)+    let b = a + fromIntegral n+        x = a + fromIntegral k+        bi = (toInteger a, toInteger b)+    map toInteger (range (a, b)) === range bi+    inRange (a, b) x === inRange bi (toInteger x)+    rangeSize (a, b) === rangeSize bi+    r <- liftIO $ tryMaybe (index (a, b) x)+    r === if inRange bi (toInteger x) then Just (index bi (toInteger x)) else Nothing++prop_showsPrec :: Property+prop_showsPrec =+  propertyCount $ do+    x <- H.forAll genWord128+    showsPrec 11 x "" === showsPrec 11 (toInteger x) ""+    read (show (Just x)) === Just x++-- Evaluate a value, returning `Nothing` if that throws an exception.+tryMaybe :: a -> IO (Maybe a)+tryMaybe x =+  either discard Just <$> try (evaluate x)+  where+    discard :: SomeException -> Maybe b+    discard _ = Nothing++-- Each `fromIntegral` here may be rewritten by one of the library's RULES, and+-- those must agree with the `fromInteger . toInteger` definition.+prop_fromIntegral_rules :: Property+prop_fromIntegral_rules =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    w <- H.forAll $ Gen.word Range.constantBounded+    w32 <- H.forAll $ Gen.word32 Range.constantBounded+    w64 <- H.forAll genWord64+    x <- H.forAll genWord128+    (fromIntegral i :: Word128) === fromInteger (toInteger i)+    (fromIntegral w :: Word128) === fromInteger (toInteger w)+    (fromIntegral w32 :: Word128) === fromInteger (toInteger w32)+    (fromIntegral w64 :: Word128) === fromInteger (toInteger w64)+    (fromIntegral x :: Int) === fromInteger (toInteger x)+    (fromIntegral x :: Word) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w32) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w64) === fromInteger (toInteger x)  prop_fromInteger :: Property prop_fromInteger =
test/Test/Data/WideWord/Word256.hs view
@@ -1,26 +1,29 @@+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE TemplateHaskell #-} module Test.Data.WideWord.Word256   ( tests   ) where -import           Control.Monad.IO.Class (liftIO)-import           Control.Monad (unless, when)+import Control.Exception (SomeException, evaluate, try)+import Control.Monad.IO.Class (liftIO)+import Control.Monad (unless, when) -import qualified Data.Binary as Binary-import           Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros+import Data.Binary qualified as Binary+import Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros                             , popCount, rotateL, rotateR, shiftL, shiftR, testBit, xor, finiteBitSize)-import           Data.Primitive.PrimArray-import           Data.Primitive.Ptr-import           Data.Word (Word64, Word8)-import           Data.WideWord+import Data.Ix (inRange, index, range, rangeSize)+import Data.Primitive.PrimArray+import Data.Primitive.Ptr+import Data.Word (Word64, Word8)+import Data.WideWord -import           Foreign (allocaBytes)-import           Foreign.Storable (Storable (..))+import Foreign (allocaBytes)+import Foreign.Storable (Storable (..)) -import           Hedgehog (Property, (===), discover)-import qualified Hedgehog as H-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Property, (===), discover)+import Hedgehog qualified as H+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range  import Test.Data.WideWord.Gen @@ -144,6 +147,104 @@   propertyCount $ do     w256 <- H.forAll genWord256     toInteger256 (signum w256) === signum (toInteger256 w256)++prop_enumFromTo :: Property+prop_enumFromTo =+  propertyCount $ do+    a <- H.forAll genWord256+    n <- H.forAll $ Gen.int (Range.linear 0 20)+    let b = a + fromIntegral n+    map toInteger [a .. b] === [toInteger a .. toInteger b]++prop_enumFromThenTo :: Property+prop_enumFromThenTo =+  propertyCount $ do+    a <- H.forAll genWord256+    step <- H.forAll $ Gen.filter (/= 0) (Gen.int (Range.linearFrom 0 (-5) 5))+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    let b = a + fromIntegral step+        c = a + fromIntegral (step * n)+    map toInteger [a, b .. c] === [toInteger a, toInteger b .. toInteger c]++prop_enumFrom_enumFromThen_bounds :: Property+prop_enumFrom_enumFromThen_bounds =+  propertyCount $ do+    n <- H.forAll $ Gen.int (Range.linear 1 10)+    let top = maxBound - fromIntegral n :: Word256+        bottom = minBound + fromIntegral n :: Word256+    map toInteger [top ..] === [toInteger top .. toInteger (maxBound :: Word256)]+    map toInteger [top, top + 1 ..] === [toInteger top .. toInteger (maxBound :: Word256)]+    map toInteger [bottom, bottom - 1 ..]+      === [toInteger bottom, toInteger bottom - 1 .. toInteger (minBound :: Word256)]++prop_toEnum_Int :: Property+prop_toEnum_Int =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    r <- liftIO $ tryMaybe (toEnum i :: Word256)+    r === if False || i >= 0 then Just (fromInteger (toInteger i)) else Nothing+    case r of+      Just x -> fromEnum x === i+      Nothing -> pure ()++prop_fromEnum_range :: Property+prop_fromEnum_range =+  propertyCount $ do+    x <- H.forAll $ Gen.choice [genWord256, fromInteger . toInteger <$> Gen.int Range.constantBounded]+    let xi = toInteger x+    r <- liftIO $ tryMaybe (fromEnum x)+    r === if xi >= toInteger (minBound :: Int) && xi <= toInteger (maxBound :: Int)+            then Just (fromInteger xi)+            else Nothing++prop_ix :: Property+prop_ix =+  propertyCount $ do+    a <- H.forAll genWord256+    n <- H.forAll $ Gen.int (Range.linear 0 10)+    k <- H.forAll $ Gen.int (Range.linear (-2) 12)+    let b = a + fromIntegral n+        x = a + fromIntegral k+        bi = (toInteger a, toInteger b)+    map toInteger (range (a, b)) === range bi+    inRange (a, b) x === inRange bi (toInteger x)+    rangeSize (a, b) === rangeSize bi+    r <- liftIO $ tryMaybe (index (a, b) x)+    r === if inRange bi (toInteger x) then Just (index bi (toInteger x)) else Nothing++prop_showsPrec :: Property+prop_showsPrec =+  propertyCount $ do+    x <- H.forAll genWord256+    showsPrec 11 x "" === showsPrec 11 (toInteger x) ""+    read (show (Just x)) === Just x++-- Evaluate a value, returning `Nothing` if that throws an exception.+tryMaybe :: a -> IO (Maybe a)+tryMaybe x =+  either discard Just <$> try (evaluate x)+  where+    discard :: SomeException -> Maybe b+    discard _ = Nothing++-- Each `fromIntegral` here may be rewritten by one of the library's RULES, and+-- those must agree with the `fromInteger . toInteger` definition.+prop_fromIntegral_rules :: Property+prop_fromIntegral_rules =+  propertyCount $ do+    i <- H.forAll $ Gen.int Range.constantBounded+    w <- H.forAll $ Gen.word Range.constantBounded+    w32 <- H.forAll $ Gen.word32 Range.constantBounded+    w64 <- H.forAll genWord64+    x <- H.forAll genWord256+    (fromIntegral i :: Word256) === fromInteger (toInteger i)+    (fromIntegral w :: Word256) === fromInteger (toInteger w)+    (fromIntegral w32 :: Word256) === fromInteger (toInteger w32)+    (fromIntegral w64 :: Word256) === fromInteger (toInteger w64)+    (fromIntegral x :: Int) === fromInteger (toInteger x)+    (fromIntegral x :: Word) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w32) === fromInteger (toInteger x)+    (fromIntegral x `asTypeOf` w64) === fromInteger (toInteger x)  prop_fromInteger :: Property prop_fromInteger =
test/Test/Data/WideWord/Word64.hs view
@@ -1,29 +1,30 @@+{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} module Test.Data.WideWord.Word64   ( tests   ) where -import           Control.Exception (ArithException, SomeException, evaluate, try)-import           Control.Monad.IO.Class (liftIO)-import           Control.Monad (unless)+import Control.Exception (ArithException, SomeException, evaluate, try)+import Control.Monad.IO.Class (liftIO)+import Control.Monad (unless) -import           Data.Bifunctor (first)-import qualified Data.Binary as Binary-import           Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros+import Data.Bifunctor (first)+import Data.Binary qualified as Binary+import Data.Bits ((.&.), (.|.), bit, complement, countLeadingZeros, countTrailingZeros                             , popCount, rotateL, rotateR, shiftL, shiftR, testBit, xor)-import           Data.Primitive.PrimArray-import           Data.Primitive.Ptr-import           Data.Word (Word8, Word64, byteSwap64)-import           Data.WideWord+import Data.Primitive.PrimArray+import Data.Primitive.Ptr+import Data.Word (Word8, Word64, byteSwap64)+import Data.WideWord -import           Foreign (allocaBytes)-import           Foreign.Storable (Storable (..))+import Foreign (allocaBytes)+import Foreign.Storable (Storable (..)) -import           Hedgehog (Property, (===), discover)-import qualified Hedgehog as H-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range+import Hedgehog (Property, (===), discover)+import Hedgehog qualified as H+import Hedgehog.Gen qualified as Gen+import Hedgehog.Range qualified as Range  import Test.Data.WideWord.Gen 
test/test128.hs view
@@ -1,9 +1,10 @@-import           Control.Monad (unless)+{-# LANGUAGE ImportQualifiedPost #-}+import Control.Monad (unless) -import           System.Exit (exitFailure)+import System.Exit (exitFailure) -import qualified Test.Data.WideWord.Int128-import qualified Test.Data.WideWord.Word128+import Test.Data.WideWord.Int128 qualified+import Test.Data.WideWord.Word128 qualified  main :: IO () main = runTests
test/test256.hs view
@@ -1,9 +1,10 @@-import           Control.Monad (unless)+{-# LANGUAGE ImportQualifiedPost #-}+import Control.Monad (unless) -import           System.Exit (exitFailure)+import System.Exit (exitFailure) -import qualified Test.Data.WideWord.Word256-import qualified Test.Data.WideWord.Int256+import Test.Data.WideWord.Word256 qualified+import Test.Data.WideWord.Int256 qualified  main :: IO () main = runTests
test/test64.hs view
@@ -1,8 +1,9 @@-import           Control.Monad (unless)+{-# LANGUAGE ImportQualifiedPost #-}+import Control.Monad (unless) -import           System.Exit (exitFailure)+import System.Exit (exitFailure) -import qualified Test.Data.WideWord.Word64+import Test.Data.WideWord.Word64 qualified  main :: IO () main = runTests
wide-word.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                wide-word-version:             0.1.9.0+version:             0.2.0.0 synopsis:            Data types for large but fixed width signed and unsigned integers description:   A library to provide data types for large (ie > 64 bits) but fixed width signed@@ -24,9 +24,9 @@ extra-source-files:  ChangeLog.md stability:           provisional cabal-version:       >= 1.10-tested-with:         GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2,-                     GHC == 9.2.4, GHC == 9.4.7, GHC == 9.6.7, GHC == 9.8.4, GHC == 9.10.2,-                     GHC == 9.12.2+tested-with:         GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.4, GHC == 9.4.7,+                     GHC == 9.6.7, GHC == 9.8.4, GHC == 9.10.3, GHC == 9.12.2,+                     GHC == 9.14.1  library   default-language:   Haskell2010@@ -111,7 +111,7 @@   hs-source-dirs:    test    build-depends:       base-                     , QuickCheck                    >= 2.9.2       && < 2.18+                     , QuickCheck                    >= 2.9.2       && < 2.20                      , quickcheck-classes            >= 0.6.3       && < 0.7.0                      , primitive                      , semirings                     >= 0.2         && < 0.8