@@ -388,31 +388,6 @@ toStreamK (Stream step state) = go state
388-- Running a 'Fold'
388-- Running a 'Fold'
389------------------------------------------------------------------------------
389------------------------------------------------------------------------------
391−-- >>> fold f = Fold.extractM . Stream.foldAddLazy f
392−-- >>> fold f = Stream.fold Fold.one . Stream.foldManyPost f
393−-- >>> fold f = Fold.extractM <=< Stream.foldAdd f
395−-- | Fold a stream using the supplied left 'Fold' and reducing the resulting
396−-- expression strictly at each step. The behavior is similar to 'foldl''. A
397−-- 'Fold' can terminate early without consuming the full stream. See the
398−-- documentation of individual 'Fold's for termination behavior.
402−-- >>> fold f = fmap fst . Stream.foldBreak f
403−-- >>> fold f = Stream.parse (Parser.fromFold f)
407−-- >>> Stream.fold Fold.sum (Stream.enumerateFromTo 1 100)
410−{-# INLINE_NORMAL fold #-}
411−fold :: Monad m => Fold m a b -> Stream m a -> m b
413− (b, _) <- foldBreak fld strm
416-- | Fold resulting in either breaking the stream or continuation of the fold.
391-- | Fold resulting in either breaking the stream or continuation of the fold.
417-- Instead of supplying the input stream in one go we can run the fold multiple
392-- Instead of supplying the input stream in one go we can run the fold multiple
418-- times, each time supplying the next segment of the input stream. If the fold
393-- times, each time supplying the next segment of the input stream. If the fold
@@ -464,6 +439,31 @@ foldBreak fld strm = do
465 nil = Stream (\_ _ -> return Stop) ()
440 nil = Stream (\_ _ -> return Stop) ()
442+-- >>> fold f = Fold.extractM . Stream.foldAddLazy f
443+-- >>> fold f = Stream.fold Fold.one . Stream.foldManyPost f
444+-- >>> fold f = Fold.extractM <=< Stream.foldAdd f
446+-- | Fold a stream using the supplied left 'Fold' and reducing the resulting
447+-- expression strictly at each step. The behavior is similar to 'foldl''. A
448+-- 'Fold' can terminate early without consuming the full stream. See the
449+-- documentation of individual 'Fold's for termination behavior.
453+-- >>> fold f = fmap fst . Stream.foldBreak f
454+-- >>> fold f = Stream.parse (Parser.fromFold f)
458+-- >>> Stream.fold Fold.sum (Stream.enumerateFromTo 1 100)
461+{-# INLINE_NORMAL fold #-}
462+fold :: Monad m => Fold m a b -> Stream m a -> m b
464+ (b, _) <- foldBreak fld strm
467-- | Append a stream to a fold lazily to build an accumulator incrementally.
467-- | Append a stream to a fold lazily to build an accumulator incrementally.
469-- Example, to continue folding a list of streams on the same sum fold:
469-- Example, to continue folding a list of streams on the same sum fold: