on master help sign in
Update idioms in "Streamly.Data.Stream" haddocks

- Add specific fold idioms - Remove wordsBy idiom

commit47270606eb72b1c2a020f3d9371a28b0b8dfeda5 authorAdithya Kumar <adithya@composewell.com> dateThu 27 Jul 2023, 02:03 (3 years ago) parent1c9ae1b
1 file changed+10−2
core/src/Streamly/Data/Stream.hs+10−2
core/src/Streamly/Data/Stream.hs+10−2
@@ -216,7 +216,16 @@ module Streamly.Data.Stream
216216 -- | Usually you can use the folds in "Streamly.Data.Fold". However, some
217217 -- folds that may be commonly used or may have an edge in performance in
218218 -- some cases are provided here.
219− -- , drain
219+ --
220+ -- Useful idioms:
221+ --
222+ -- >>> foldlM' f a = Stream.fold (Fold.foldlM' f a)
223+ -- >>> foldl1 f = Stream.fold (Fold.foldl1' f)
224+ -- >>> foldl' f a = Stream.fold (Fold.foldl' f a)
225+ -- >>> drain = Stream.fold Fold.drain
226+ -- >>> mapM_ f = Stream.fold (Fold.drainMapM f)
227+ -- >>> length = Stream.fold Fold.length
228+ -- >>> head = Stream.fold Fold.one
220229 , toList
221230
222231 -- * Mapping
@@ -428,7 +437,6 @@ module Streamly.Data.Stream
428437 -- >>> splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
429438 -- >>> groupsBy eq f = Stream.parseMany (Parser.groupBy eq f)
430439 -- >>> groupsByRolling eq f = Stream.parseMany (Parser.groupByRolling eq f)
431− -- >>> wordsBy p f = Stream.parseMany (Parser.wordBy p f)
432440 -- >>> groupsOf n f = Stream.foldMany (Fold.take n f)
433441 , foldMany -- XXX Rename to foldRepeat
434442 , groupsOf