integer-roots 1.0 → 1.0.0.1
raw patch · 6 files changed
+26/−37 lines, 6 filesdep ~basedep ~smallcheck
Dependency ranges changed: base, smallcheck
Files
- Math/NumberTheory/Roots/General.hs +8/−0
- README.md +2/−2
- changelog.md +5/−1
- integer-roots.cabal +6/−7
- test-suite/Math/NumberTheory/TestUtils.hs +4/−4
- test-suite/Math/NumberTheory/TestUtils/Wrappers.hs +1/−23
Math/NumberTheory/Roots/General.hs view
@@ -9,6 +9,7 @@ -- {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} module Math.NumberTheory.Roots.General@@ -23,6 +24,9 @@ import Data.List (foldl', sortBy) import Data.Maybe (isJust) import GHC.Exts (Int(..), Word(..), quotInt#, int2Word#, word2Int#, int2Double#, double2Int#, isTrue#, Ptr(..), indexWord16OffAddr#, (/##), (**##), (<#), (*#), (-#), (+#))+#if MIN_VERSION_base(4,16,0)+import GHC.Exts (word16ToWord#)+#endif import GHC.Integer.GMP.Internals (Integer(..), shiftLInteger, shiftRInteger) import GHC.Integer.Logarithms (integerLog2#) import Numeric.Natural (Natural)@@ -251,7 +255,11 @@ smallOddPrimes :: [Integer] smallOddPrimes = takeWhile (< spBound)+#if MIN_VERSION_base(4,16,0)+ $ map (\(I# k#) -> S# (word2Int# (word16ToWord# (indexWord16OffAddr# smallPrimesAddr# k#))))+#else $ map (\(I# k#) -> S# (word2Int# (indexWord16OffAddr# smallPrimesAddr# k#)))+#endif [1 .. smallPrimesLength - 1] where !(Ptr smallPrimesAddr#) = smallPrimesPtr
README.md view
@@ -1,4 +1,4 @@-# integer-roots [](https://travis-ci.org/Bodigrim/integer-roots) [](https://hackage.haskell.org/package/integer-roots) [](https://matrix.hackage.haskell.org/package/integer-roots) [](http://stackage.org/lts/package/integer-roots) [](http://stackage.org/nightly/package/integer-roots)+# integer-roots [](https://github.com/Bodigrim/integer-roots/actions?query=workflow%3AHaskell-CI) [](https://hackage.haskell.org/package/integer-roots) [](https://matrix.hackage.haskell.org/package/integer-roots) [](http://stackage.org/lts/package/integer-roots) [](http://stackage.org/nightly/package/integer-roots) Calculating integer roots and testing perfect powers of arbitrary precision. @@ -37,7 +37,7 @@ ```haskell > integerSquareRoot (3037000502^2) 3037000501-> isqrt (2^1024) == 2^1024+> integerSquareRoot (2^1024) == 2^1024 True ```
changelog.md view
@@ -1,3 +1,7 @@+# 1.0.0.1++* Compatibility fixes for GHC 9.2.+ # 1.0 -Initial release.+* Initial release.
integer-roots.cabal view
@@ -1,5 +1,5 @@ name: integer-roots-version: 1.0+version: 1.0.0.1 cabal-version: >=1.10 build-type: Simple license: MIT@@ -12,7 +12,7 @@ description: Calculating integer roots and testing perfect powers of arbitrary precision. Originally part of <https://hackage.haskell.org/package/arithmoi arithmoi> package. category: Math, Algorithms, Number Theory author: Daniel Fischer, Andrew Lelechenko-tested-with: GHC ==8.0.2 GHC ==8.2.2 GHC ==8.4.4 GHC ==8.6.5 GHC ==8.8.2+tested-with: GHC ==8.0.2 GHC ==8.2.2 GHC ==8.4.4 GHC ==8.6.5 GHC ==8.8.4 GHC ==8.10.4 GHC ==9.0.1 extra-source-files: changelog.md README.md@@ -24,7 +24,7 @@ library build-depends: base >=4.9 && <5,- integer-gmp <1.1+ integer-gmp <1.2 exposed-modules: Math.NumberTheory.Roots other-modules:@@ -37,13 +37,13 @@ Math.NumberTheory.Utils.BitMask Math.NumberTheory.Utils.FromIntegral default-language: Haskell2010- ghc-options: -Wall -Widentities+ ghc-options: -Wall -Widentities -Wno-deprecations -Wcompat test-suite integer-roots-tests build-depends: base >=4.9 && <5, integer-roots,- smallcheck >=1.1.3 && <1.2,+ smallcheck >=1.2 && <1.3, tasty >=0.10, tasty-hunit >=0.9 && <0.11, tasty-quickcheck >=0.9 && <0.11,@@ -59,7 +59,7 @@ main-is: Test.hs default-language: Haskell2010 hs-source-dirs: test-suite- ghc-options: -Wall -Widentities+ ghc-options: -Wall -Widentities -Wcompat test-suite integer-roots-doctests type: exitcode-stdio-1.0@@ -69,4 +69,3 @@ base, doctest >= 0.8 default-language: Haskell2010- buildable: False
test-suite/Math/NumberTheory/TestUtils.hs view
@@ -38,12 +38,12 @@ import Test.SmallCheck.Series (Positive(..), NonNegative(..), Serial(..)) import Test.Tasty import Test.Tasty.SmallCheck as SC-import Test.Tasty.QuickCheck as QC hiding (Positive, getPositive, NonNegative, generate, getNonNegative)+import Test.Tasty.QuickCheck as QC hiding (Positive(..), NonNegative(..), generate) import Data.Bits import Data.Int+import Data.Kind import Data.Word-import GHC.Exts import Numeric.Natural import Math.NumberTheory.TestUtils.Wrappers@@ -59,12 +59,12 @@ class (f (g x)) => (f `Compose` g) x instance (f (g x)) => (f `Compose` g) x -type family ConcatMap (w :: * -> Constraint) (cs :: [*]) :: Constraint+type family ConcatMap (w :: Type -> Constraint) (cs :: [Type]) :: Constraint where ConcatMap w '[] = () ConcatMap w (c ': cs) = (w c, ConcatMap w cs) -type family Matrix (as :: [* -> Constraint]) (w :: * -> *) (bs :: [*]) :: Constraint+type family Matrix (as :: [Type -> Constraint]) (w :: Type -> Type) (bs :: [Type]) :: Constraint where Matrix '[] w bs = () Matrix (a ': as) w bs = (ConcatMap (a `Compose` w) bs, Matrix as w bs)
test-suite/Math/NumberTheory/TestUtils/Wrappers.hs view
@@ -27,7 +27,7 @@ import Control.Applicative import Data.Functor.Classes -import Test.Tasty.QuickCheck as QC hiding (Positive, NonNegative, generate, getNonNegative, getPositive)+import Test.Tasty.QuickCheck as QC hiding (Positive(..), NonNegative(..)) import Test.SmallCheck.Series (Positive(..), NonNegative(..), Serial(..), Series) -------------------------------------------------------------------------------@@ -51,16 +51,10 @@ ------------------------------------------------------------------------------- -- Positive from smallcheck -deriving instance Functor Positive- instance (Num a, Ord a, Arbitrary a) => Arbitrary (Positive a) where arbitrary = Positive <$> (arbitrary `suchThat` (> 0)) shrink (Positive x) = Positive <$> filter (> 0) (shrink x) -instance (Num a, Bounded a) => Bounded (Positive a) where- minBound = Positive 1- maxBound = Positive (maxBound :: a)- instance Eq1 Positive where liftEq eq (Positive a) (Positive b) = a `eq` b @@ -73,16 +67,10 @@ ------------------------------------------------------------------------------- -- NonNegative from smallcheck -deriving instance Functor NonNegative- instance (Num a, Ord a, Arbitrary a) => Arbitrary (NonNegative a) where arbitrary = NonNegative <$> (arbitrary `suchThat` (>= 0)) shrink (NonNegative x) = NonNegative <$> filter (>= 0) (shrink x) -instance (Num a, Bounded a) => Bounded (NonNegative a) where- minBound = NonNegative 0- maxBound = NonNegative (maxBound :: a)- instance Eq1 NonNegative where liftEq eq (NonNegative a) (NonNegative b) = a `eq` b @@ -91,16 +79,6 @@ instance Show1 NonNegative where liftShowsPrec shw _ p (NonNegative a) = shw p a------------------------------------------------------------------------------------ NonZero from QuickCheck--instance (Monad m, Num a, Eq a, Serial m a) => Serial m (NonZero a) where- series = NonZero <$> series `suchThatSerial` (/= 0)--instance (Eq a, Num a, Enum a, Bounded a) => Bounded (NonZero a) where- minBound = if minBound == (0 :: a) then NonZero (succ minBound) else NonZero minBound- maxBound = if maxBound == (0 :: a) then NonZero (pred maxBound) else NonZero maxBound ------------------------------------------------------------------------------- -- Huge