Add example to express foldrM in terms of foldr

This commit is contained in:
Harendra Kumar 2024-01-25 23:24:12 +05:30
parent 84b4c91d44
commit 30c5a56ff9

View File

@ -572,8 +572,12 @@ foldAdd f =
-- >>> Stream.foldrM step (return False) s
-- True
--
-- >>> import Control.Monad (join)
-- >>> foldrM f z = join $ Stream.foldr f z
--
{-# INLINE_NORMAL foldrM #-}
foldrM :: Monad m => (a -> m b -> m b) -> m b -> Stream m a -> m b
-- foldrM f z = join . Streamly.Internal.Data.Stream.StreamD.Type.foldr f z
foldrM f z (Stream step state) = go SPEC state
where
{-# INLINE_LATE go #-}