packages feed

mod 0.2.0.1 → 0.2.1.0

raw patch · 6 files changed

+43/−22 lines, 6 filesdep ~ghc-bignum

Dependency ranges changed: ghc-bignum

Files

Data/Mod.hs view
@@ -352,8 +352,10 @@   :: Natural -- Value   -> Natural -- Modulo   -> Maybe Natural+invertModInternal 0 1 = Just 0 invertModInternal x m = case integerRecipMod# (toInteger x) m of-  (# | () #) -> Nothing+  -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26017+  (# | () #) -> if m == 1 then Just 0 else Nothing   (# y | #)  -> Just y {-# INLINABLE invertModInternal #-} @@ -383,11 +385,10 @@ #endif {-# INLINABLE [1] (^%) #-} -{-# SPECIALISE [1] (^%) ::-  KnownNat m => Mod m -> Integer -> Mod m,-  KnownNat m => Mod m -> Natural -> Mod m,-  KnownNat m => Mod m -> Int     -> Mod m,-  KnownNat m => Mod m -> Word    -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Integer -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Natural -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Int     -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Word    -> Mod m #-}  {-# RULES "powMod/2/Integer"     forall x. x ^% (2 :: Integer) = let u = x in u*u
Data/Mod/Compat.hs view
@@ -14,9 +14,14 @@   , remWord2#   ) where -#ifdef aarch64_HOST_ARCH-import GHC.Exts (Word(..), Word#, timesWord#)+#if defined(aarch64_HOST_ARCH) && __GLASGOW_HASKELL__ < 912 +import GHC.Exts (Word(..), Word#)++#if __GLASGOW_HASKELL__ < 904++import GHC.Exts (timesWord#)+ timesWord2# :: Word# -> Word# -> (# Word#, Word# #) timesWord2# x y = (# z, timesWord# x y #)   where@@ -24,6 +29,12 @@ {-# INLINE timesWord2# #-}  foreign import capi unsafe "aarch64.h umulh" c_umulh :: Word -> Word -> Word++#else++import GHC.Exts (timesWord2#)++#endif  remWord2# :: Word# -> Word# -> Word# -> Word# remWord2# lo hi m = r
Data/Mod/Word.hs view
@@ -335,6 +335,8 @@ invertMod mx@(Mod !x) = case natVal mx of   NatJ#{}   -> tooLargeModulus   NatS# 0## -> Nothing+  -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26017+  NatS# 1## -> Just 0   NatS# m#  -> Mod <$> invertModWord x (W# m#)  invertModWord :: Word -> Word -> Maybe Word@@ -442,11 +444,10 @@       f b  e acc = f (mulMod m b b) (e `P.quot` 2) (if odd e then mulMod m b acc else acc) {-# INLINABLE [1] (^%) #-} -{-# SPECIALISE [1] (^%) ::-  KnownNat m => Mod m -> Integer -> Mod m,-  KnownNat m => Mod m -> Natural -> Mod m,-  KnownNat m => Mod m -> Int     -> Mod m,-  KnownNat m => Mod m -> Word    -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Integer -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Natural -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Int     -> Mod m #-}+{-# SPECIALISE [1] (^%) :: KnownNat m => Mod m -> Word    -> Mod m #-}  {-# RULES "powMod/2/Integer"     forall x. x ^% (2 :: Integer) = let u = x in u*u
changelog.md view
@@ -1,3 +1,7 @@+# 0.2.1.0++* Fix `invertMod (0 :: Mod 1)`.+ # 0.2.0.1  * Fix build on `aarch64`.
mod.cabal view
@@ -1,5 +1,5 @@ name:          mod-version:       0.2.0.1+version:       0.2.1.0 cabal-version: >=1.10 build-type:    Simple license:       MIT@@ -15,7 +15,7 @@   Originally part of the <https://hackage.haskell.org/package/arithmoi arithmoi> package. category:      Math, Number Theory author:        Andrew Lelechenko <andrew.lelechenko@gmail.com>-tested-with:   GHC ==9.0.2 GHC ==9.2.5 GHC ==9.4.4 GHC ==9.6.1+tested-with:   GHC ==9.0.2 GHC ==9.2.8 GHC ==9.4.8 GHC ==9.6.7 GHC ==9.8.4 GHC ==9.10.2 GHC ==9.12.2 GHC ==9.14.1 extra-source-files:   changelog.md   README.md@@ -36,15 +36,15 @@ library   build-depends:     base >=4.15 && <5,-    deepseq,-    ghc-bignum+    deepseq <1.6,+    ghc-bignum <1.5   if flag(semirings)     build-depends:-      semirings >= 0.5+      semirings >=0.5 && <0.8   if flag(vector)     build-depends:-      primitive,-      vector >= 0.12+      primitive <0.10,+      vector >=0.12 && <0.14   exposed-modules:     Data.Mod     Data.Mod.Word@@ -53,7 +53,7 @@   default-language: Haskell2010   ghc-options: -Wall -O2 -Wno-deprecations -Wcompat -  if(arch(aarch64))+  if(arch(aarch64) && impl(ghc <9.12))     c-sources: cbits/aarch64.c     include-dirs: cbits @@ -63,7 +63,7 @@     mod,     quickcheck-classes-base,     tasty >=0.10,-    tasty-quickcheck >=0.9 && <0.11+    tasty-quickcheck >=0.9 && <0.12   if flag(semirings)     build-depends:       containers,
test/Test.hs view
@@ -58,6 +58,8 @@   [ testGroup "Mod 1" $     testProperty "fromInteger"       (fromIntegerProp (Proxy :: Proxy 1)) :+    testProperty "invertMod"+      (invertMod (0 :: Mod 1) == Just 0) :     map lawsToTest (laws1 (Proxy :: Proxy (Mod 1)))   , testMod(2310)   , testMod(2^16-1)@@ -103,6 +105,8 @@   , testGroup "Word.Mod 1" $     testProperty "fromInteger"       (fromIntegerWordProp (Proxy :: Proxy 1)) :+    testProperty "invertMod"+      (Word.invertMod (0 :: Word.Mod 1) == Just 0) :     map lawsToTest (laws1 (Proxy :: Proxy (Word.Mod 1)))   , testMod(2310)   , testMod(2^16-1)