@@ -388,31 +388,6 @@ toStreamK (Stream step state) = go state
388388-- Running a 'Fold'
389389------------------------------------------------------------------------------
390390
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
394−
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.
399−--
400−-- Definitions:
401−--
402−-- >>> fold f = fmap fst . Stream.foldBreak f
403−-- >>> fold f = Stream.parse (Parser.fromFold f)
404−--
405−-- Example:
406−--
407−-- >>> Stream.fold Fold.sum (Stream.enumerateFromTo 1 100)
408−-- 5050
409−--
410−{-# INLINE_NORMAL fold #-}
411−fold :: Monad m => Fold m a b -> Stream m a -> m b
412−fold fld strm = do
413− (b, _) <- foldBreak fld strm
414− return b
415−
416391-- | Fold resulting in either breaking the stream or continuation of the fold.
417392-- Instead of supplying the input stream in one go we can run the fold multiple
418393-- times, each time supplying the next segment of the input stream. If the fold
@@ -464,6 +439,31 @@ foldBreak fld strm = do
464439
465440 nil = Stream (\_ _ -> return Stop) ()
466441
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
445+
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.
450+--
451+-- Definitions:
452+--
453+-- >>> fold f = fmap fst . Stream.foldBreak f
454+-- >>> fold f = Stream.parse (Parser.fromFold f)
455+--
456+-- Example:
457+--
458+-- >>> Stream.fold Fold.sum (Stream.enumerateFromTo 1 100)
459+-- 5050
460+--
461+{-# INLINE_NORMAL fold #-}
462+fold :: Monad m => Fold m a b -> Stream m a -> m b
463+fold fld strm = do
464+ (b, _) <- foldBreak fld strm
465+ return b
466+
467467-- | Append a stream to a fold lazily to build an accumulator incrementally.
468468--
469469-- Example, to continue folding a list of streams on the same sum fold: