diff -Nru haskell-integer-logarithms-1.0.1/changelog.md haskell-integer-logarithms-1.0.2/changelog.md --- haskell-integer-logarithms-1.0.1/changelog.md 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/changelog.md 2017-07-07 12:03:58.000000000 +0000 @@ -1,3 +1,9 @@ +1.0.2 +----- + +- Deprecate `Math.NumberTheory.Power.Integer` and `Math.NumberTheory.Power.Natural` modules + `(^)` is as good as custom methods. + 1.0.1 ----- diff -Nru haskell-integer-logarithms-1.0.1/debian/changelog haskell-integer-logarithms-1.0.2/debian/changelog --- haskell-integer-logarithms-1.0.1/debian/changelog 2017-07-06 23:51:57.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/debian/changelog 2017-09-10 17:53:12.000000000 +0000 @@ -1,3 +1,11 @@ +haskell-integer-logarithms (1.0.2-1) unstable; urgency=medium + + * New upstream release + * Disable test suite. + Requires quickcheck newer than current LTS Haskell. + + -- Sean Whitton Sun, 10 Sep 2017 10:53:11 -0700 + haskell-integer-logarithms (1.0.1-1) unstable; urgency=low * Initial release. diff -Nru haskell-integer-logarithms-1.0.1/debian/control haskell-integer-logarithms-1.0.2/debian/control --- haskell-integer-logarithms-1.0.1/debian/control 2017-07-06 23:51:57.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/debian/control 2017-09-10 17:52:51.000000000 +0000 @@ -8,8 +8,9 @@ cdbs, ghc, ghc-prof, - libghc-quickcheck2-dev (>= 2.9), - libghc-quickcheck2-dev (<< 2.10), +# these are newer than current LTS +# libghc-quickcheck2-dev (>= 2.10), +# libghc-quickcheck2-dev (<< 2.11), libghc-smallcheck-dev (>= 1.1), libghc-smallcheck-dev (<< 1.2), libghc-tasty-dev (>= 0.10), @@ -17,7 +18,7 @@ libghc-tasty-hunit-dev (>= 0.9), libghc-tasty-hunit-dev (<< 0.10), libghc-tasty-quickcheck-dev (>= 0.8), - libghc-tasty-quickcheck-dev (<< 0.9), + libghc-tasty-quickcheck-dev (<< 0.10), libghc-tasty-smallcheck-dev (>= 0.8), libghc-tasty-smallcheck-dev (<< 0.9), Build-Depends-Indep: ghc-doc, diff -Nru haskell-integer-logarithms-1.0.1/debian/rules haskell-integer-logarithms-1.0.2/debian/rules --- haskell-integer-logarithms-1.0.1/debian/rules 2017-07-06 23:51:57.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/debian/rules 2017-09-10 17:52:26.000000000 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/make -f -DEB_ENABLE_TESTS = yes +# needs QuickCheck 2.10 which is newer than current LTS +DEB_ENABLE_TESTS = no DEB_SETUP_BIN_NAME = debian/hlibrary.setup DEB_CABAL_PACKAGE = integer-logarithms DEB_DEFAULT_COMPILER = ghc diff -Nru haskell-integer-logarithms-1.0.1/integer-logarithms.cabal haskell-integer-logarithms-1.0.2/integer-logarithms.cabal --- haskell-integer-logarithms-1.0.1/integer-logarithms.cabal 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/integer-logarithms.cabal 2017-07-07 12:03:58.000000000 +0000 @@ -1,5 +1,5 @@ name: integer-logarithms -version: 1.0.1 +version: 1.0.2 cabal-version: >= 1.10 author: Daniel Fischer copyright: (c) 2011 Daniel Fischer @@ -29,7 +29,8 @@ GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, - GHC==8.0.1 + GHC==8.0.2, + GHC==8.2.1 extra-source-files : readme.md changelog.md @@ -47,7 +48,7 @@ default-language: Haskell2010 hs-source-dirs: src build-depends: - base >= 4.3 && < 4.10, + base >= 4.3 && < 4.11, array >= 0.3 && < 0.6, ghc-prim < 0.6 if impl(ghc >= 7.10) @@ -97,16 +98,14 @@ integer-logarithms, tasty >= 0.10 && < 0.12, tasty-smallcheck >= 0.8 && < 0.9, - tasty-quickcheck >= 0.8 && < 0.9, + tasty-quickcheck >= 0.8 && < 0.10, tasty-hunit >= 0.9 && < 0.10, - QuickCheck >= 2.9 && < 2.10, + QuickCheck >= 2.10 && < 2.11, smallcheck >= 1.1 && < 1.2 if !impl(ghc >= 7.10) build-depends: nats >= 1.1 && <1.2 other-modules: Math.NumberTheory.LogarithmsTests - Math.NumberTheory.Powers.IntegerTests - Math.NumberTheory.Powers.NaturalTests - other-modules: Math.NumberTheory.TestUtils + Orphans diff -Nru haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Logarithms.hs haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Logarithms.hs --- haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Logarithms.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Logarithms.hs 2017-07-07 12:03:58.000000000 +0000 @@ -53,9 +53,6 @@ import Data.Array.Base (unsafeAt) #endif -import Math.NumberTheory.Powers.Integer -import Math.NumberTheory.Powers.Natural - -- | Calculate the integer logarithm for an arbitrary base. -- The base must be greater than 1, the second argument, the number -- whose logarithm is sought, must be positive, otherwise an error is thrown. @@ -163,7 +160,7 @@ integerLog10' n | n < 10 = 0 | n < 100 = 1 - | otherwise = ex + integerLog10' (n `quot` integerPower 10 ex) + | otherwise = ex + integerLog10' (n `quot` 10 ^ ex) where ln = I# (integerLog2# n) -- u/v is a good approximation of log 2/log 10 @@ -179,7 +176,7 @@ naturalLog10' n | n < 10 = 0 | n < 100 = 1 - | otherwise = ex + naturalLog10' (n `quot` naturalPower 10 ex) + | otherwise = ex + naturalLog10' (n `quot` 10 ^ ex) where ln = I# (naturalLog2# n) -- u/v is a good approximation of log 2/log 10 @@ -204,7 +201,7 @@ ex = fromInteger ((fromIntegral u * fromIntegral ln) `quot` fromIntegral v) in case u of 1 -> ln `quot` v -- a power of 2, easy - _ -> ex + integerLogBase' b (n `quot` integerPower b ex) + _ -> ex + integerLogBase' b (n `quot` b ^ ex) | otherwise = let -- shift b so that 16 <= bi < 32 bi = fromInteger (b `shiftR` (lb-4)) -- we choose an approximation of log 2 / log (bi+1) to @@ -219,7 +216,7 @@ v = fromIntegral $ logArr `unsafeAt` (ix+1) w = v + u*fromIntegral (lb-4) ex = fromInteger ((u * fromIntegral ln) `quot` w) - in ex + integerLogBase' b (n `quot` integerPower b ex) + in ex + integerLogBase' b (n `quot` b ^ ex) where lb = integerLog2' b ln = integerLog2' n @@ -240,7 +237,7 @@ ex = fromNatural ((fromIntegral u * fromIntegral ln) `quot` fromIntegral v) in case u of 1 -> ln `quot` v -- a power of 2, easy - _ -> ex + naturalLogBase' b (n `quot` naturalPower b ex) + _ -> ex + naturalLogBase' b (n `quot` b ^ ex) | otherwise = let -- shift b so that 16 <= bi < 32 bi = fromNatural (b `shiftR` (lb-4)) -- we choose an approximation of log 2 / log (bi+1) to @@ -255,7 +252,7 @@ v = fromIntegral $ logArr `unsafeAt` (ix+1) w = v + u*fromIntegral (lb-4) ex = fromNatural ((u * fromIntegral ln) `quot` w) - in ex + naturalLogBase' b (n `quot` naturalPower b ex) + in ex + naturalLogBase' b (n `quot` b ^ ex) where lb = naturalLog2' b ln = naturalLog2' n diff -Nru haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Powers/Integer.hs haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Powers/Integer.hs --- haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Powers/Integer.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Powers/Integer.hs 2017-07-07 12:03:58.000000000 +0000 @@ -10,15 +10,15 @@ -- or 'Word' exponent. -- {-# LANGUAGE CPP #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE BangPatterns #-} module Math.NumberTheory.Powers.Integer + {-# DEPRECATED "It is no faster than (^)" #-} ( integerPower , integerWordPower ) where -import GHC.Exts -import GHC.Integer.Logarithms.Compat (wordLog2#) +#if !MIN_VERSION_base(4,8,0) +import Data.Word +#endif -- | Power of an 'Integer' by the left-to-right repeated squaring algorithm. -- This needs two multiplications in each step while the right-to-left @@ -34,29 +34,10 @@ -- /Warning:/ No check for the negativity of the exponent is performed, -- a negative exponent is interpreted as a large positive exponent. integerPower :: Integer -> Int -> Integer -integerPower b (I# e#) = power b (int2Word# e#) +integerPower = (^) +{-# DEPRECATED integerPower "Use (^) instead" #-} -- | Same as 'integerPower', but for exponents of type 'Word'. integerWordPower :: Integer -> Word -> Integer -integerWordPower b (W# w#) = power b w# - -power :: Integer -> Word# -> Integer -power b w# - | isTrue# (w# `eqWord#` 0##) = 1 - | isTrue# (w# `eqWord#` 1##) = b - | otherwise = go (wordLog2# w# -# 1#) b (b*b) - where - go 0# l h = if isTrue# ((w# `and#` 1##) `eqWord#` 0##) then l*l else (l*h) - go i# l h - | w# `hasBit#` i# = go (i# -# 1#) (l*h) (h*h) - | otherwise = go (i# -# 1#) (l*l) (l*h) - --- | A raw version of testBit for 'Word#'. -hasBit# :: Word# -> Int# -> Bool -hasBit# w# i# = isTrue# (((w# `uncheckedShiftRL#` i#) `and#` 1##) `neWord#` 0##) - -#if __GLASGOW_HASKELL__ < 707 --- The times they are a-changing. The types of primops too :( -isTrue# :: Bool -> Bool -isTrue# = id -#endif +integerWordPower = (^) +{-# DEPRECATED integerWordPower "Use (^) instead" #-} diff -Nru haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Powers/Natural.hs haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Powers/Natural.hs --- haskell-integer-logarithms-1.0.1/src/Math/NumberTheory/Powers/Natural.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/src/Math/NumberTheory/Powers/Natural.hs 2017-07-07 12:03:58.000000000 +0000 @@ -10,16 +10,17 @@ -- or 'Word' exponent. -- {-# LANGUAGE CPP #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE BangPatterns #-} module Math.NumberTheory.Powers.Natural + {-# DEPRECATED "It is no faster than (^)" #-} ( naturalPower , naturalWordPower ) where -import GHC.Exts +#if !MIN_VERSION_base(4,8,0) +import Data.Word +#endif + import Numeric.Natural -import GHC.Integer.Logarithms.Compat (wordLog2#) -- | Power of an 'Natural' by the left-to-right repeated squaring algorithm. -- This needs two multiplications in each step while the right-to-left @@ -35,29 +36,10 @@ -- /Warning:/ No check for the negativity of the exponent is performed, -- a negative exponent is interpreted as a large positive exponent. naturalPower :: Natural -> Int -> Natural -naturalPower b (I# e#) = power b (int2Word# e#) +naturalPower = (^) +{-# DEPRECATED naturalPower "Use (^) instead" #-} -- | Same as 'naturalPower', but for exponents of type 'Word'. naturalWordPower :: Natural -> Word -> Natural -naturalWordPower b (W# w#) = power b w# - -power :: Natural -> Word# -> Natural -power b w# - | isTrue# (w# `eqWord#` 0##) = 1 - | isTrue# (w# `eqWord#` 1##) = b - | otherwise = go (wordLog2# w# -# 1#) b (b*b) - where - go 0# l h = if isTrue# ((w# `and#` 1##) `eqWord#` 0##) then l*l else (l*h) - go i# l h - | w# `hasBit#` i# = go (i# -# 1#) (l*h) (h*h) - | otherwise = go (i# -# 1#) (l*l) (l*h) - --- | A raw version of testBit for 'Word#'. -hasBit# :: Word# -> Int# -> Bool -hasBit# w# i# = isTrue# (((w# `uncheckedShiftRL#` i#) `and#` 1##) `neWord#` 0##) - -#if __GLASGOW_HASKELL__ < 707 --- The times they are a-changing. The types of primops too :( -isTrue# :: Bool -> Bool -isTrue# = id -#endif +naturalWordPower = (^) +{-# DEPRECATED naturalWordPower "Use (^) instead" #-} diff -Nru haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/LogarithmsTests.hs haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/LogarithmsTests.hs --- haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/LogarithmsTests.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/LogarithmsTests.hs 2017-07-07 12:03:58.000000000 +0000 @@ -27,6 +27,9 @@ import Math.NumberTheory.Logarithms import Math.NumberTheory.TestUtils +-- Arbitrary Natural +import Orphans () + -- | Check that 'integerLogBase' returns the largest integer @l@ such that @b@ ^ @l@ <= @n@ and @b@ ^ (@l@+1) > @n@. integerLogBaseProperty :: Positive Integer -> Positive Integer -> Bool integerLogBaseProperty (Positive b) (Positive n) = b == 1 || b ^ l <= n && b ^ (l + 1) > n diff -Nru haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/Powers/IntegerTests.hs haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/Powers/IntegerTests.hs --- haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/Powers/IntegerTests.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/Powers/IntegerTests.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ --- | --- Module: Math.NumberTheory.Powers.IntegerTests --- Copyright: (c) 2016 Andrew Lelechenko --- Licence: MIT --- Maintainer: Andrew Lelechenko --- Stability: Provisional --- --- Tests for Math.NumberTheory.Powers.Integer --- - -{-# LANGUAGE CPP #-} - -{-# OPTIONS_GHC -fno-warn-type-defaults #-} - -module Math.NumberTheory.Powers.IntegerTests - ( testSuite - ) where - -import Test.Tasty - -#if MIN_VERSION_base(4,8,0) -#else -import Data.Word -#endif - -import Math.NumberTheory.Powers.Integer -import Math.NumberTheory.TestUtils - --- | Check that 'integerPower' == '^'. -integerPowerProperty :: Integer -> Power Int -> Bool -integerPowerProperty a (Power b) = integerPower a b == a ^ b - --- | Check that 'integerWordPower' == '^'. -integerWordPowerProperty :: Integer -> Power Word -> Bool -integerWordPowerProperty a (Power b) = integerWordPower a b == a ^ b - -testSuite :: TestTree -testSuite = testGroup "Integer" - [ testSmallAndQuick "integerPower" integerPowerProperty - , testSmallAndQuick "integerWordPower" integerWordPowerProperty - ] diff -Nru haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/Powers/NaturalTests.hs haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/Powers/NaturalTests.hs --- haskell-integer-logarithms-1.0.1/test-suite/Math/NumberTheory/Powers/NaturalTests.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/test-suite/Math/NumberTheory/Powers/NaturalTests.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ --- | --- Module: Math.NumberTheory.Powers.NaturalTests --- Copyright: (c) 2016 Andrew Lelechenko --- Licence: MIT --- Maintainer: Andrew Lelechenko --- Stability: Provisional --- --- Tests for Math.NumberTheory.Powers.Natural --- - -{-# LANGUAGE CPP #-} - -{-# OPTIONS_GHC -fno-warn-type-defaults #-} - -module Math.NumberTheory.Powers.NaturalTests - ( testSuite - ) where - -import Test.Tasty - -#if MIN_VERSION_base(4,8,0) -#else -import Data.Word -#endif - -import Math.NumberTheory.Powers.Natural -import Numeric.Natural -import Math.NumberTheory.TestUtils - --- | Check that 'naturalPower' == '^'. -naturalPowerProperty :: Natural -> Power Int -> Bool -naturalPowerProperty a (Power b) = naturalPower a b == a ^ b - --- | Check that 'naturalWordPower' == '^'. -naturalWordPowerProperty :: Natural -> Power Word -> Bool -naturalWordPowerProperty a (Power b) = naturalWordPower a b == a ^ b - -testSuite :: TestTree -testSuite = testGroup "Natural" - [ testSmallAndQuick "naturalPower" naturalPowerProperty - , testSmallAndQuick "naturalWordPower" naturalWordPowerProperty - ] diff -Nru haskell-integer-logarithms-1.0.1/test-suite/Orphans.hs haskell-integer-logarithms-1.0.2/test-suite/Orphans.hs --- haskell-integer-logarithms-1.0.1/test-suite/Orphans.hs 1970-01-01 00:00:00.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/test-suite/Orphans.hs 2017-07-07 12:03:58.000000000 +0000 @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} +module Orphans () where + +import Numeric.Natural (Natural) +import Test.QuickCheck (Arbitrary (..)) + +-- | The QuickCheck-2.10 doesn't define the Arbitrary Natural instance +-- We define own instance (and not use quickcheck-instance) to break +-- the cycle in tests. +instance Arbitrary Natural where + arbitrary = fmap (fromInteger . abs) arbitrary + shrink = map (fromInteger . abs) . shrink . fromIntegral diff -Nru haskell-integer-logarithms-1.0.1/test-suite/Test.hs haskell-integer-logarithms-1.0.2/test-suite/Test.hs --- haskell-integer-logarithms-1.0.1/test-suite/Test.hs 2017-01-26 12:27:02.000000000 +0000 +++ haskell-integer-logarithms-1.0.2/test-suite/Test.hs 2017-07-07 12:03:58.000000000 +0000 @@ -1,8 +1,6 @@ import Test.Tasty import qualified Math.NumberTheory.LogarithmsTests as Logarithms -import qualified Math.NumberTheory.Powers.IntegerTests as PowerInteger -import qualified Math.NumberTheory.Powers.NaturalTests as PowerNatural main :: IO () main = defaultMain tests @@ -10,6 +8,4 @@ tests :: TestTree tests = testGroup "All" [ Logarithms.testSuite - , PowerInteger.testSuite - , PowerNatural.testSuite ]