packages feed

lean-peano 0.1.1.0 → 1.0.0.0

raw patch · 2 files changed

+51/−49 lines, 2 filesdep ~basedep ~deepseqPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, deepseq

API changes (from Hackage documentation)

Files

lean-peano.cabal view
@@ -1,13 +1,8 @@ cabal-version: >= 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.------ see: https://github.com/sol/hpack------ hash: 64e91e616abbba7139ad4f000d8a6a1505b2a315175f0489493a319d6a76ac89- name:           lean-peano-version:        0.1.1.0+version:        1.0.0.0+synopsis:       A maximally lazy, simple implementation of the Peano numbers with minimal dependencies description:    Please see the README on GitHub at <https://github.com/oisdk/lean-peano#readme> homepage:       https://github.com/oisdk/lean-peano#readme bug-reports:    https://github.com/oisdk/lean-peano/issues@@ -27,7 +22,7 @@  custom-setup   setup-depends:-      base+      base >=4.10.0.0 && <5     , Cabal     , cabal-doctest  >=1.0.6 && <1.1 @@ -39,8 +34,8 @@       src   ghc-options: -Wall -fwarn-incomplete-record-updates -fwarn-incomplete-uni-patterns -fwarn-redundant-constraints -Wcompat   build-depends:-      base >=4.7 && <5-    , deepseq+      base >=4.10.0.0 && <5+    , deepseq >= 1.1.0.0   default-language: Haskell2010  test-suite doctests@@ -51,7 +46,7 @@   ghc-options: -Wall -fwarn-incomplete-record-updates -fwarn-incomplete-uni-patterns -fwarn-redundant-constraints -Wcompat -threaded   build-depends:       QuickCheck-    , base+    , base >=4.10.0.0 && <5     , base-compat     , deepseq     , doctest
test/Spec.hs view
@@ -6,6 +6,7 @@ {-# LANGUAGE TypeApplications    #-}  import           Hedgehog+import           Hedgehog.Main import qualified Hedgehog.Gen        as Gen import qualified Hedgehog.Range      as Range @@ -30,81 +31,87 @@     let zt = op (fromInteger @a x) (fromInteger y)     zb === toInteger zt +nats :: Gen Nat+nats = Gen.integral (Range.linear 0 1000)+ holdsForLength :: Foldable f => (a -> Bool) -> f a -> Int holdsForLength p = flip (foldr f id) 0 where   f e a i | p e = a (i + 1)           | otherwise = i -enumProps-    :: forall a.-       (Enum a, Show a, Ord a)-    => (Int -> Bool) -> Gen Int -> Gen a -> Property-enumProps p ig eg = property $ do-    x <- forAll ig+prop_Enum :: Property+prop_Enum = property $ do+    x <- forAll (Gen.integral (Range.linear 0 1000))     annotate "from . to"-    (fromEnum . toEnum @a) x === x+    (fromEnum @Nat . toEnum) x === x     annotate "to . from"-    n <- forAll eg+    n <- forAll nats     (toEnum . fromEnum) n === n     annotate "[n..]"     let lhs1 = take 100 $ map fromEnum [n..]         rhs1 = take 100 [fromEnum n..]-        len1 = min (holdsForLength p lhs1) (holdsForLength p rhs1)+        len1 = min (holdsForLength (>= 0) lhs1) (holdsForLength (>= 0) rhs1)     take len1 lhs1 === take len1 rhs1     annotate "[n,m..]"-    m <- forAll eg+    m <- forAll nats     let lhs2 = take 100 $ map fromEnum [n,m..]         rhs2 = take 100 [fromEnum n, fromEnum m..]-        len2 = min (holdsForLength p lhs2) (holdsForLength p rhs2)+        len2 = min (holdsForLength (>= 0) lhs2) (holdsForLength (>= 0) rhs2)     take len2 lhs2 === take len2 rhs2     when (m >= n) $ do         annotate "[n..m]"         map fromEnum [n..m] === [fromEnum n..fromEnum m]-    l <- forAll eg+    l <- forAll nats     when (((l > n) == (n > m)) && (l /= n)) $ do         annotate "[l,n..m]"         map fromEnum [l,n..m] === [fromEnum l, fromEnum n..fromEnum m] --prop_PeanoAdd :: Property-prop_PeanoAdd = binaryProp @Nat (+) 0 1000 (\_ _ -> True)--prop_PeanoMul :: Property-prop_PeanoMul = binaryProp @Nat (*) 0 1000 (\_ _ -> True)+prop_Add :: Property+prop_Add = binaryProp @Nat (+) 0 1000 (\_ _ -> True) -prop_PeanoSub :: Property-prop_PeanoSub = withDiscards 1000 $ binaryProp @Nat (-) 0 1000 (>=)+prop_Mul :: Property+prop_Mul = binaryProp @Nat (*) 0 1000 (\_ _ -> True) -prop_PeanoRem :: Property-prop_PeanoRem = binaryProp @Nat rem 0 1000 (\_ y -> y > 0)+prop_Sub :: Property+prop_Sub = withDiscards 1000 $ binaryProp @Nat (-) 0 1000 (>=) -prop_PeanoQuot :: Property-prop_PeanoQuot = binaryProp @Nat quot 0 1000 (\_ y -> y > 0)+prop_Rem :: Property+prop_Rem = binaryProp @Nat rem 0 1000 (\_ y -> y > 0) --- prop_PeanoOrd :: Property--- prop_PeanoOrd = property $ ord (Gen.integral (Range.linear @Nat 0 1000))(\n -> Gen.integral (Range.linear n (n+5)))+prop_quot :: Property+prop_quot = binaryProp @Nat quot 0 1000 (\_ y -> y > 0) -prop_PeanoEnum :: Property-prop_PeanoEnum =-    enumProps-        (>= 0)-        (Gen.integral (Range.linear 0 1000))-        (Gen.integral (Range.linear @Nat 0 1000))+prop_ord :: Property+prop_ord = property $ do+  x <- forAll nats+  y <- forAll nats+  annotate "<="+  (x <= y) === (fromEnum x <= fromEnum y)+  (x <= x) === True+  annotate "<"+  (x < y) === (fromEnum x < fromEnum y)+  (x < x) === False+  annotate ">="+  (x >= y) === (y <= x)+  annotate ">"+  (x > y) === (y < x)+  annotate "compare"+  compare x y === compare (fromEnum x) (fromEnum y) -prop_PeanoInRange :: Property-prop_PeanoInRange = property $ do+prop_InRange :: Property+prop_InRange = property $ do     l <- forAll (Gen.integral (Range.linear Z 100))     u <- forAll (Gen.integral (Range.linear l (l+100)))     i <- forAll (Gen.integral (Range.linear 0 300))     inRange (l,u) i === (l <= i &&  i <= u) -prop_PeanoIndex :: Property-prop_PeanoIndex = property $ do+prop_Index :: Property+prop_Index = property $ do     l <- forAll (Gen.integral (Range.linear Z 100))     u <- forAll (Gen.integral (Range.linear l (l+100)))     i <- forAll (Gen.integral (Range.linear l u))     unless (inRange (l,u) i) discard     index (l,u) i === fromEnum (i - l) -main :: IO Bool-main = checkParallel $$(discover)+main :: IO ()+main = defaultMain [checkParallel $$(discover)]