@@ -335,6 +335,7 @@ module Streamly.Internal.Data.Fold.Type
336 , foldlM'
336 , foldlM'
337 , foldl1'
337 , foldl1'
339 , foldtM'
340 , foldtM'
@@ -550,6 +551,18 @@ foldl1' step = fmap toMaybe $ foldl' step1 Nothing'
550 step1 Nothing' a = Just' a
551 step1 Nothing' a = Just' a
551 step1 (Just' x) a = Just' $ step x a
552 step1 (Just' x) a = Just' $ step x a
554+-- | Like 'foldl1\'' but with a monadic step function.
557+{-# INLINE foldlM1' #-}
558+foldlM1' :: Monad m => (a -> a -> m a) -> Fold m a (Maybe a)
559+foldlM1' step = fmap toMaybe $ foldlM' step1 (return Nothing')
563+ step1 Nothing' a = return $ Just' a
564+ step1 (Just' x) a = Just' <$> step x a
553------------------------------------------------------------------------------
566------------------------------------------------------------------------------
554-- Right fold constructors
567-- Right fold constructors
555------------------------------------------------------------------------------
568------------------------------------------------------------------------------