@@ -87,6 +87,7 @@ module Streamly.Internal.Data.Unfold
8787 , identity
8888 , const
8989 , replicateM
90+ , repeatM
9091 , fromList
9192 , fromListM
9293 , enumerateFromStepIntegral
@@ -404,6 +405,15 @@ replicateM n = Unfold step inject
404405 then Stop
405406 else Yield x (x, (i - 1))
406407
408+-- | Generates an infinite stream repeating the seed.
409+--
410+{-# INLINE repeatM #-}
411+repeatM :: Monad m => Unfold m a a
412+repeatM = Unfold step return
413+ where
414+ {-# INLINE_LATE step #-}
415+ step x = return $ Yield x x
416+
407417-- | Convert a list of pure values to a 'Stream'
408418{-# INLINE_LATE fromList #-}
409419fromList :: Monad m => Unfold m [a] a