packages feed

circular 0.4.0.1 → 0.4.0.2

raw patch · 5 files changed

+44/−42 lines, 5 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -5,6 +5,11 @@ ## Unreleased changes  +## 0.4.0.2++-   Tooling updtes related to GHC 9.2.1.++ ## 0.4.0.1  -   Minor changes mostly related to tooling.
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
circular.cabal view
@@ -1,6 +1,6 @@-cabal-version:  2.0+cabal-version:  3.0 name:           circular-version:        0.4.0.1+version:        0.4.0.2 synopsis:       Circular fixed-sized mutable vectors description:    Please see the README at <https://github.com/dschrempf/circular#readme> category:       Math, Data Structures@@ -9,7 +9,7 @@ author:         Dominik Schrempf maintainer:     dominik.schrempf@gmail.com copyright:      Dominik Schrempf (2021)-license:        BSD3+license:        BSD-3-Clause license-file:   LICENSE build-type:     Simple extra-source-files:
src/Data/Stack/Circular.hs view
@@ -72,8 +72,8 @@ replicate n x   | n <= 0 = error "empty: maximum size must be one or larger"   | otherwise = do-    v <- VM.replicate n x-    return $ MStack v 0+      v <- VM.replicate n x+      return $ MStack v 0  -- | Convert a vector to a circular stack with size being equal to the length of -- the vector. The first element of the vector is the oldest element of the@@ -86,8 +86,8 @@ fromVector v   | n == 0 = error "fromVector: empty vector"   | otherwise = do-    mv <- VG.thaw v-    return $ MStack mv (n - 1)+      mv <- VG.thaw v+      return $ MStack mv (n - 1)   where     n = VG.length v @@ -134,11 +134,11 @@   | i0 >= 0 = VG.freeze $ VM.unsafeSlice i0 k v   -- Now we now that i0 is negative.   | otherwise = do-    -- The length of r is i'.-    r <- VG.freeze $ VM.unsafeTake i' v-    -- The length of l has to be k-i'. So we have to drop n-(k-i')=n+i0.-    l <- VG.freeze $ VM.unsafeDrop (n + i0) v-    return $ l VG.++ r+      -- The length of r is i'.+      r <- VG.freeze $ VM.unsafeTake i' v+      -- The length of l has to be k-i'. So we have to drop n-(k-i')=n+i0.+      l <- VG.freeze $ VM.unsafeDrop (n + i0) v+      return $ l VG.++ r   where     n = VM.length v     i' = i + 1@@ -222,7 +222,7 @@ foldKV k i f x v = do   x' <- f x <$> VM.unsafeRead v i   -- Assume that i-1 is non-negative.-  foldKV (k -1) (i -1) f x' v+  foldKV (k - 1) (i - 1) f x' v  -- | See 'foldM' but only over the @k@ youngest elements on the stack. --@@ -235,9 +235,9 @@   | k <= i' = foldKV k i f x v   -- Or not.   | otherwise = do-    x' <- foldKV i' i f x v-    -- Continue from the end of the vector.-    foldKV (k - i') (n -1) f x' v+      x' <- foldKV i' i f x v+      -- Continue from the end of the vector.+      foldKV (k - i') (n - 1) f x' v   where     n = VM.length v     i' = i + 1
test/Data/Stack/CircularSpec.hs view
@@ -38,7 +38,7 @@     s <- getSize     n <- choose (1, s + 1)     v <- VB.fromList <$> vector n-    i <- choose (0, n -1)+    i <- choose (0, n - 1)     return $ runST $ C.fromVectorWithIndex i v >>= C.freeze  se :: PrimMonad m => m (C.MStack VB.Vector (PrimState m) Int)@@ -70,21 +70,21 @@ prop_push x v   | VB.length v == 0 = True   | otherwise =-    runST (C.fromVector v >>= C.push x >>= C.toVector)-      == VB.tail v VB.++ VB.singleton x+      runST (C.fromVector v >>= C.push x >>= C.toVector)+        == VB.tail v VB.++ VB.singleton x  prop_many_pushes :: [Int] -> VB.Vector Int -> Bool prop_many_pushes xs v   | VB.length v == 0 = True   | length xs <= VB.length v = True   | otherwise =-    runST-      ( do-          ms <- C.fromVector v-          ms' <- foldM (flip C.push) ms xs-          C.toVector ms'-      )-      == sol+      runST+        ( do+            ms <- C.fromVector v+            ms' <- foldM (flip C.push) ms xs+            C.toVector ms'+        )+        == sol   where     nl = length xs     nv = VB.length v@@ -99,18 +99,18 @@ prop_push_take k l v   | VB.length v == 0 = True   | otherwise =-    -- traceShow-    --   ( "Input:" ++ show k ++ " " ++ show l ++ " " ++ show v-    --       ++ " k': "-    --       ++ show k'-    --       ++ " Stack full: "-    --       ++ show stackFull-    --       ++ " Stack take: "-    --       ++ show stackTake-    --       ++ " Sol: "-    --       ++ show solution-    --   ) $-    stackTake == solution+      -- traceShow+      --   ( "Input:" ++ show k ++ " " ++ show l ++ " " ++ show v+      --       ++ " k': "+      --       ++ show k'+      --       ++ " Stack full: "+      --       ++ show stackFull+      --       ++ " Stack take: "+      --       ++ show stackTake+      --       ++ " Sol: "+      --       ++ show solution+      --   ) $+      stackTake == solution   where     -- stackFull = runST $ do     --   m <- C.fromVector v@@ -142,7 +142,7 @@ prop_fold_independent_of_index v   | VB.length v == 0 = True   | otherwise = do-    [solV] == nub solSs+      [solV] == nub solSs   where     n = VB.length v     solV = VB.sum v