@@ -680,7 +680,7 @@ yieldM = K.yieldM
680-- @since 0.6.0
680-- @since 0.6.0
681{-# INLINE fromIndices #-}
681{-# INLINE fromIndices #-}
682fromIndices :: (IsStream t, Monad m) => (Int -> a) -> t m a
682fromIndices :: (IsStream t, Monad m) => (Int -> a) -> t m a
683−fromIndices = fromStreamD . D.fromIndices
683+fromIndices = fromStreamS . S.fromIndices
@@ -691,13 +691,17 @@ fromIndices = fromStreamD . D.fromIndices
691-- Generate an infinite stream, whose values are the output of a monadic
691-- Generate an infinite stream, whose values are the output of a monadic
692-- function @f@ applied on the corresponding index. Index starts at 0.
692-- function @f@ applied on the corresponding index. Index starts at 0.
694-- @since 0.6.0
696-- @since 0.6.0
695−{-# INLINE fromIndicesM #-}
697+{-# INLINE_EARLY fromIndicesM #-}
696fromIndicesM :: (IsStream t, MonadAsync m) => (Int -> m a) -> t m a
698fromIndicesM :: (IsStream t, MonadAsync m) => (Int -> m a) -> t m a
697−fromIndicesM gen = go 0
699+fromIndicesM = K.fromIndicesM
699− go i = K.mkStream $ \st stp sng yld -> do
701+{-# RULES "fromIndicesM serial" fromIndicesM = fromIndicesMSerial #-}
700− K.foldStreamShared st stp sng yld (gen i |: go (i + 1))
702+{-# INLINE fromIndicesMSerial #-}
703+fromIndicesMSerial :: MonadAsync m => (Int -> m a) -> SerialT m a
704+fromIndicesMSerial = fromStreamS . S.fromIndicesM