on master help sign in
Fix replicateM in unfolds, don't perform action if not required.
c4f90b5adithyaov
src/Streamly/Internal/Data/Unfold.hs+6−6
@@ -503,12 +503,12 @@ replicateM n = Unfold step inject
503 inject x = return (x, n)
503 inject x = return (x, n)
504
504
505 {-# INLINE_LATE step #-}
505 {-# INLINE_LATE step #-}
506− step (x, i) = do
506+ step (x, i) =
507− x1 <- x
508− return
509− $ if i <= 0
507+ if i <= 0
510− then Stop
508+ then return Stop
509+ else do
510+ x1 <- x
511− else Yield x1 (x, i - 1)
511+ return $ Yield x1 (x, i - 1)
512
512
513-- | Generates an infinite stream repeating the seed.
513-- | Generates an infinite stream repeating the seed.
514--
514--