@@ -23,6 +23,7 @@ import GHC.Exception (ErrorCall)
2323import System.Random (randomRIO)
2424
2525import qualified Data.Foldable as F
26+import qualified Data.List as List
2627import qualified Streamly.Prelude as S
2728import qualified Streamly.Internal.Data.Stream.IsStream as Internal
2829import qualified Streamly.Internal.Data.Pipe as Pipe
@@ -287,6 +288,23 @@ sourceFoldMapWith :: (S.IsStream t, Semigroup (t m Int))
287288 => Int -> Int -> t m Int
288289sourceFoldMapWith value n = S.concatMapFoldableWith (<>) S.yield [n..n+value]
289290
291+{-# INLINE concatForFoldableWith #-}
292+concatForFoldableWith :: (S.IsStream t, Semigroup (t m Int))
293+ => Int -> Int -> t m Int
294+concatForFoldableWith value n =
295+ S.concatForFoldableWith (<>) [n..n+value] S.yield
296+
297+{-# INLINE concatFoldableWith #-}
298+concatFoldableWith :: (S.IsStream t, Semigroup (t m Int))
299+ => Int -> Int -> t m Int
300+concatFoldableWith value n =
301+ let step x =
302+ if x <= n + value
303+ then Just (S.yield x, x + 1)
304+ else Nothing
305+ list = List.unfoldr step n
306+ in S.concatFoldableWith (<>) list
307+
290308{-# INLINE sourceFoldMapWithStream #-}
291309sourceFoldMapWithStream :: (S.IsStream t, Semigroup (t m Int))
292310 => Int -> Int -> t m Int