on master help sign in
Rearrange the elimination section

Similar to Streamly.Internal.Data.IsStream.Eliminate

commit796bb224f2e2cebec84151ac77013d6cd35af511 authorHarendra Kumar <harendra@composewell.com> dateFri 2 Apr 2021, 14:18 (6 years ago) parent1b6fb5b
2 files changed+28−27
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+3 src/Streamly/Prelude.hs+25−27
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+3
@@ -206,6 +206,9 @@ import Prelude hiding
206206-- individual elements and we can loop over them as we deem fit. For example,
207207-- this can be used to convert a streamly stream into other stream types.
208208--
209+-- All the folds in this module can be expressed in terms of 'uncons', however
210+-- the specific implementations are generally more efficient.
211+--
209212-- @since 0.1.0
210213{-# INLINE uncons #-}
211214uncons :: (IsStream t, Monad m) => SerialT m a -> m (Maybe (a, t m a))
src/Streamly/Prelude.hs+25−27
@@ -320,6 +320,8 @@
320320module Streamly.Prelude
321321 (
322322 -- * Construction
323+ -- | Functions ending in the general shape @b -> t m a@
324+
323325 -- ** Primitives
324326 -- | Primitives to construct a stream from pure values or monadic actions.
325327 -- All other stream construction and generation combinators described later
@@ -386,17 +388,22 @@ module Streamly.Prelude
386388 , fromFoldableM
387389
388390 -- * Elimination
391+ -- | Functions ending in the general shape @t m a -> m b@
392+
393+ -- ** Running a 'Fold'
394+ -- $runningfolds
395+
396+ , fold
397+ , foldMany
389398
390399 -- ** Deconstruction
391− -- | It is easy to express all the folds in terms of the 'uncons' primitive,
392− -- however the specific implementations provided later are generally more
393− -- efficient.
394− --
400+ -- | Functions ending in the general shape @t m a -> m (b, t m a)@
401+
395402 , uncons
396403 , tail
397404 , init
398405
399− -- ** Folding
406+ -- ** General Folds
400407-- | In imperative terms a fold can be considered as a loop over the stream
401408-- that reduces the stream to a single value.
402409-- Left and right folds both use a fold function @f@ and an identity element
@@ -466,24 +473,19 @@ module Streamly.Prelude
466473-- the previous step. However, it is possible to fold parts of the stream in
467474-- parallel and then combine the results using a monoid.
468475
469− -- ** Right Folds
476+ -- *** Right Folds
470477 -- $rightfolds
471478 , foldrM
472479 , foldr
473480
474− -- ** Left Folds
481+ -- *** Left Folds
475482 -- $leftfolds
476483 , foldl'
477484 , foldl1'
478485 , foldlM'
479486
480− -- ** Composable Left Folds
481− -- $runningfolds
482−
483− , fold
484− , foldMany
485−
486− -- ** Full Folds
487+ -- ** Specific Folds
488+ -- *** Full Folds
487489 -- | Folds that are guaranteed to evaluate the whole stream.
488490
489491 -- -- ** To Summary (Full Folds)
@@ -503,17 +505,7 @@ module Streamly.Prelude
503505 , minimum
504506 , the
505507
506− -- ** Lazy Folds
507− --
508− -- | Folds that generate a lazy structure. Note that the generated
509− -- structure may not be lazy if the underlying monad is strict.
510−
511− -- -- ** To Containers (Full Folds)
512− -- -- | Convert or divert a stream into an output structure, container or
513− -- sink.
514− , toList
515−
516− -- ** Partial Folds
508+ -- *** Partial Folds
517509 -- | Folds that may terminate before evaluating the whole stream. These
518510 -- folds strictly evaluate the stream until the result is determined.
519511
@@ -540,6 +532,14 @@ module Streamly.Prelude
540532 , and
541533 , or
542534
535+ -- *** To Containers
536+ -- | Convert a stream into a container holding all the values.
537+ , toList
538+
539+ -- ** Folding Concurrently
540+ , (|$.)
541+ , (|&.)
542+
543543 -- ** Multi-Stream folds
544544 , eqBy
545545 , cmpBy
@@ -553,8 +553,6 @@ module Streamly.Prelude
553553 -- $application
554554 , (|$)
555555 , (|&)
556− , (|$.)
557− , (|&.)
558556
559557 -- * Transformation
560558