@@ -128,6 +128,7 @@ module Streamly.Internal.Data.Stream.StreamD
129 -- ** Specialized Folds
129 -- ** Specialized Folds
131 , tapAsync
132 , tapAsync
132 , tapRate
133 , tapRate
133 , pollCounts
134 , pollCounts
@@ -3279,6 +3280,39 @@ tap (Fold fstep initial extract) (Stream step state) = Stream step' Nothing
3279 void $ extract acc
3280 void $ extract acc
3280 return $ Stop
3281 return $ Stop
3283+{-# INLINE_NORMAL tapOffsetEvery #-}
3284+tapOffsetEvery :: Monad m
3285+ => Int -> Int -> Fold m a b -> Stream m a -> Stream m a
3286+tapOffsetEvery offset n (Fold fstep initial extract) (Stream step state) =
3287+ Stream step' Nothing
3291+ {-# INLINE_LATE step' #-}
3292+ step' _ Nothing = do
3294+ return $ Skip (Just (r, state, offset `mod` n))
3296+ step' gst (Just (acc, st, count)) | count <= 0 = do
3300+ !acc' <- fstep acc x
3301+ return $ Yield x (Just (acc', s, n - 1))
3302+ Skip s -> return $ Skip (Just (acc, s, count))
3307+ step' gst (Just (acc, st, count)) = do
3310+ Yield x s -> return $ Yield x (Just (acc, s, count - 1))
3311+ Skip s -> return $ Skip (Just (acc, s, count))
3282{-# INLINE_NORMAL pollCounts #-}
3316{-# INLINE_NORMAL pollCounts #-}
3283pollCounts
3317pollCounts
3284 :: MonadAsync m
3318 :: MonadAsync m