on master help sign in
Fix bug in findIndices and add a regression test. Fixes #311.
a97e3f3Pranay Sashank
Changelog.md+7
@@ -1,3 +1,10 @@
1+## Unreleased
2+
3+### Bug Fixes
4+
5+* Fix a bug that caused `findIndices` to increment the index during
6+ a Skip condition.
7+
1## 0.7.0
8## 0.7.0
2
9
3### Breaking changes
10### Breaking changes
src/Streamly/Streams/StreamD.hs+1−1
@@ -960,7 +960,7 @@ findIndices p (Stream step state) = Stream step' (state, 0)
960 r <- step (adaptState gst) st
960 r <- step (adaptState gst) st
961 return $ case r of
961 return $ case r of
962 Yield x s -> if p x then Yield i (s, i+1) else Skip (s, i+1)
962 Yield x s -> if p x then Yield i (s, i+1) else Skip (s, i+1)
963− Skip s -> Skip (s, i+1)
963+ Skip s -> Skip (s, i)
964 Stop -> Stop
964 Stop -> Stop
965
965
966{-# INLINE toListRev #-}
966{-# INLINE toListRev #-}
test/Prop.hs+4
@@ -620,6 +620,10 @@ transformCombineOpsOrdered constr desc eq t = do
620
620
621 prop (desc <> " findIndices") $
621 prop (desc <> " findIndices") $
622 transform (findIndices odd) t (S.findIndices odd)
622 transform (findIndices odd) t (S.findIndices odd)
623+ prop (desc <> " findIndices . filter") $
624+ transform (findIndices odd . filter odd)
625+ t
626+ (S.findIndices odd . S.filter odd)
623 prop (desc <> " elemIndices") $
627 prop (desc <> " elemIndices") $
624 transform (elemIndices 0) t (S.elemIndices 0)
628 transform (elemIndices 0) t (S.elemIndices 0)
625
629