@@ -91,31 +91,32 @@ module Streamly.Prelude
93 -- ** Specialized Folds
93 -- ** Specialized Folds
95+ -- Filtering folds: extract parts of the stream
101+ -- Conditional folds: may terminate early based on a condition
100 , notElem
105 , notElem
101− , length
106+ , lookup
114+ -- Full folds - need to go through all elements
106 , maximum
116 , maximum
107 , minimum
117 , minimum
109 , product
119 , product
120 -- ** Map and Fold
121 -- ** Map and Fold
@@ -126,7 +127,14 @@ module Streamly.Prelude
126 , toHandle
127 , toHandle
128 -- * Transformation
129 -- * Transformation
129− -- ** By folding (scans)
130+ -- ** Mapping
136+ -- | Scan is a transformation by continuously folding the result with the
137+ -- next element of the stream.
131 , scanlM'
139 , scanlM'
@@ -141,20 +149,19 @@ module Streamly.Prelude
141 , dropWhile
149 , dropWhile
142 , dropWhileM
150 , dropWhileM
144− -- ** Mapping
152+ -- ** Inserting
145− , Serial.map
153+ , intersperseM
149− -- ** Map and Filter
153 -- ** Reordering
155 -- ** Reordering
154 , reverse
156 , reverse
156− -- ** Inserting
158+ -- ** Indices
157− , intersperseM
159+ , findIndices
162+ -- ** Map and Filter
159 -- * Zipping
166 -- * Zipping
160 , zipWith
167 , zipWith
@@ -303,10 +310,29 @@ unfoldrMSerial step seed = fromStreamS (S.unfoldrM step seed)
303-- Specialized Generation
310-- Specialized Generation
304------------------------------------------------------------------------------
311------------------------------------------------------------------------------
313+-- Faster than yieldM because there is no bind. Usually we can construct a
314+-- stream from a pure value using "pure" in an applicative, however in case of
315+-- Zip streams pure creates an infinite stream.
317+-- | Create a singleton stream from a pure value. In monadic streams, 'pure' or
318+-- 'return' can be used in place of 'yield', however, in Zip applicative
319+-- streams 'pure' is equivalent to 'repeat'.
306{-# INLINE yield #-}
322{-# INLINE yield #-}
307yield :: IsStream t => a -> t m a
323yield :: IsStream t => a -> t m a
308yield a = K.yield a
324yield a = K.yield a
326+-- | Create a singleton stream from a monadic action. Same as @m \`consM` nil@
327+-- but more efficient.
330+-- > toList $ yieldM getLine
310{-# INLINE yieldM #-}
336{-# INLINE yieldM #-}
311yieldM :: (Monad m, IsStream t) => m a -> t m a
337yieldM :: (Monad m, IsStream t) => m a -> t m a
312yieldM m = K.yieldM m
338yieldM m = K.yieldM m