on master help sign in
Add since annotations on Streamly.Data.Stream module
commit301c0a337aea723eedce35c9658c4928a5fb8f32 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateWed 7 Sep 2022, 13:59 (4 years ago) parented85ad8
10 files changed+93−33
core/src/Streamly/Internal/Data/Stream/Bottom.hs+15−3 core/src/Streamly/Internal/Data/Stream/Eliminate.hs+6−2 core/src/Streamly/Internal/Data/Stream/Enumerate.hs+20−20 core/src/Streamly/Internal/Data/Stream/Exception.hs+6 core/src/Streamly/Internal/Data/Stream/Expand.hs+9−3 core/src/Streamly/Internal/Data/Stream/Generate.hs+8−2 core/src/Streamly/Internal/Data/Stream/Lift.hs+3 core/src/Streamly/Internal/Data/Stream/Reduce.hs+1 core/src/Streamly/Internal/Data/Stream/Transform.hs+21−3 core/src/Streamly/Internal/Data/Stream/Type.hs+4
core/src/Streamly/Internal/Data/Stream/Bottom.hs+15−3
@@ -102,6 +102,7 @@ import Streamly.Internal.Data.Stream.Type
102102-- Construct a stream from a list of pure values. This is more efficient than
103103-- 'fromFoldable'.
104104--
105+-- @since 0.9.0
105106{-# INLINE fromList #-}
106107fromList :: Monad m => [a] -> Stream m a
107108fromList = fromStreamK . Common.fromList
@@ -183,7 +184,7 @@ relTimesWith = fmap snd . timesWith
183184--
184185-- >>> fold f = Fold.finish . Stream.foldContinue f
185186--
186−-- /Internal/
187+-- @since 0.9.0
187188{-# INLINE foldContinue #-}
188189foldContinue :: Monad m => Fold m a b -> Stream m a -> Fold m a b
189190foldContinue f s = D.foldContinue f $ toStreamD s
@@ -214,6 +215,7 @@ fold fl strm = D.fold fl $ D.fromStreamK $ toStreamK strm
214215--
215216-- /Not fused/
216217--
218+-- @since 0.9.0
217219{-# INLINE foldBreak #-}
218220foldBreak :: Monad m => Fold m a b -> Stream m a -> m (b, Stream m a)
219221{-
@@ -265,6 +267,7 @@ map f = fromStreamD . D.map f . toStreamD
265267-- :}
266268-- [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0]
267269--
270+-- @since 0.9.0
268271{-# INLINE postscan #-}
269272postscan :: Monad m => Fold m a b -> Stream m a -> Stream m b
270273postscan fld = fromStreamD . D.postscanOnce fld . toStreamD
@@ -325,8 +328,7 @@ catMaybes = fromStreamD . D.catMaybes . toStreamD
325328--
326329-- >>> scanMaybe f = Stream.catMaybes . Stream.postscan f
327330--
328−-- /Pre-release/
329−--
331+-- @since 0.9.0
330332{-# INLINE scanMaybe #-}
331333scanMaybe :: Monad m => Fold m a (Maybe b) -> Stream m a -> Stream m b
332334scanMaybe p = catMaybes . postscan p
@@ -337,6 +339,7 @@ scanMaybe p = catMaybes . postscan p
337339
338340-- | Take first 'n' elements from the stream and discard the rest.
339341--
342+-- @since 0.9.0
340343{-# INLINE take #-}
341344take :: Monad m => Int -> Stream m a -> Stream m a
342345-- take n = scanMaybe (Fold.taking n)
@@ -344,6 +347,7 @@ take n m = fromStreamD $ D.take n $ toStreamD m
344347
345348-- | End the stream as soon as the predicate fails on an element.
346349--
350+-- @since 0.9.0
347351{-# INLINE takeWhile #-}
348352takeWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a
349353-- takeWhile p = scanMaybe (Fold.takingEndBy_ (not . p))
@@ -356,6 +360,7 @@ takeEndBy p m = fromStreamD $ D.takeEndBy p $ toStreamD m
356360
357361-- | Discard first 'n' elements from the stream and take the rest.
358362--
363+-- @since 0.9.0
359364{-# INLINE drop #-}
360365drop :: Monad m => Int -> Stream m a -> Stream m a
361366-- drop n = scanMaybe (Fold.dropping n)
@@ -370,6 +375,7 @@ drop n m = fromStreamD $ D.drop n $ toStreamD m
370375--
371376-- >>> findIndices p = Stream.fold (Fold.findIndices p)
372377--
378+-- @since 0.9.0
373379{-# INLINE findIndices #-}
374380findIndices :: Monad m => (a -> Bool) -> Stream m a -> Stream m Int
375381-- findIndices p = scanMaybe (Fold.findIndices p)
@@ -395,6 +401,7 @@ findIndices p m = fromStreamD $ D.findIndices p (toStreamD m)
395401-- >>> Stream.fold Fold.toList $ Stream.intersperseM (putChar '.' >> return ',') $ Stream.trace putChar input
396402-- he.l.l.o."h,e,l,l,o"
397403--
404+-- @since 0.9.0
398405{-# INLINE intersperseM #-}
399406intersperseM :: Monad m => m a -> Stream m a -> Stream m a
400407intersperseM m = fromStreamD . D.intersperseM m . toStreamD
@@ -414,6 +421,7 @@ intersperseM m = fromStreamD . D.intersperseM m . toStreamD
414421--
415422-- >>> reverse = Stream.foldlT (flip Stream.cons) Stream.nil
416423--
424+-- @since 0.9.0
417425{-# INLINE reverse #-}
418426reverse :: Monad m => Stream m a -> Stream m a
419427reverse s = fromStreamD $ D.reverse $ toStreamD s
@@ -442,6 +450,7 @@ reverse' =
442450-- generation function is monadic, unlike 'concatMap', it can produce an
443451-- effect at the beginning of each iteration of the inner loop.
444452--
453+-- @since 0.9.0
445454{-# INLINE concatMapM #-}
446455concatMapM :: Monad m => (a -> m (Stream m b)) -> Stream m a -> Stream m b
447456concatMapM f m = fromStreamD $ D.concatMapM (fmap toStreamD . f) (toStreamD m)
@@ -454,6 +463,7 @@ concatMapM f m = fromStreamD $ D.concatMapM (fmap toStreamD . f) (toStreamD m)
454463-- >>> concatMap f = Stream.concat . fmap f
455464-- >>> concatMap f = Stream.unfoldMany (Unfold.lmap f Unfold.fromStream)
456465--
466+-- @since 0.9.0
457467{-# INLINE concatMap #-}
458468concatMap ::Monad m => (a -> Stream m b) -> Stream m a -> Stream m b
459469concatMap f m = fromStreamD $ D.concatMap (toStreamD . f) (toStreamD m)
@@ -500,6 +510,7 @@ foldManyPost f m = fromStreamD $ D.foldManyPost f (toStreamD m)
500510
501511-- | Like 'zipWith' but using a monadic zipping function.
502512--
513+-- @since 0.9.0
503514{-# INLINE zipWithM #-}
504515zipWithM :: Monad m =>
505516 (a -> b -> m c) -> Stream m a -> Stream m b -> Stream m c
@@ -517,6 +528,7 @@ zipWithM f m1 m2 = fromStreamD $ D.zipWithM f (toStreamD m1) (toStreamD m2)
517528-- >>> Stream.fold Fold.toList $ Stream.zipWith (+) s1 s2
518529-- [5,7,9]
519530--
531+-- @since 0.9.0
520532{-# INLINE zipWith #-}
521533zipWith :: Monad m => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c
522534zipWith f m1 m2 = fromStreamD $ D.zipWith f (toStreamD m1) (toStreamD m2)
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+6−2
@@ -127,6 +127,7 @@ import Prelude hiding (foldr, reverse)
127127--
128128-- /Not fused/
129129--
130+-- @since 0.9.0
130131{-# INLINE uncons #-}
131132uncons :: Monad m => Stream m a -> m (Maybe (a, Stream m a))
132133uncons m = fmap (fmap (fmap fromStreamK)) $ K.uncons (toStreamK m)
@@ -230,8 +231,7 @@ parseK = parse
230231--
231232-- Note: @parse p@ is not the same as @head . parseMany p@ on an empty stream.
232233--
233−-- /Pre-release/
234−--
234+-- @since 0.9.0
235235{-# INLINE [3] parse #-}
236236parse :: MonadThrow m => Parser m a b -> Stream m a -> m b
237237parse = parseD . PRD.fromParserK
@@ -247,6 +247,7 @@ parseBreakD parser strm = do
247247--
248248-- /Not fused/
249249--
250+-- @since 0.9.0
250251{-# INLINE parseBreak #-}
251252parseBreak :: MonadThrow m => Parser m a b -> Stream m a -> m (b, Stream m a)
252253parseBreak p strm = fmap f $ K.parseBreak (PRD.fromParserK p) (toStreamK strm)
@@ -265,6 +266,7 @@ parseBreak p strm = fmap f $ K.parseBreak (PRD.fromParserK p) (toStreamK strm)
265266-- >>> Stream.isPrefixOf (Stream.fromList "hello") (Stream.fromList "hello" :: Stream IO Char)
266267-- True
267268--
269+-- @since 0.9.0
268270{-# INLINE isPrefixOf #-}
269271isPrefixOf :: (Monad m, Eq a) => Stream m a -> Stream m a -> m Bool
270272isPrefixOf m1 m2 = D.isPrefixOf (toStreamD m1) (toStreamD m2)
@@ -330,6 +332,7 @@ isSuffixOf suffix stream = reverse suffix `isPrefixOf` reverse stream
330332-- >>> Stream.isSubsequenceOf (Stream.fromList "hlo") (Stream.fromList "hello" :: Stream IO Char)
331333-- True
332334--
335+-- @since 0.9.0
333336{-# INLINE isSubsequenceOf #-}
334337isSubsequenceOf :: (Monad m, Eq a) => Stream m a -> Stream m a -> m Bool
335338isSubsequenceOf m1 m2 = D.isSubsequenceOf (toStreamD m1) (toStreamD m2)
@@ -347,6 +350,7 @@ isSubsequenceOf m1 m2 = D.isSubsequenceOf (toStreamD m1) (toStreamD m2)
347350--
348351-- Space: @O(1)@
349352--
353+-- @since 0.9.0
350354{-# INLINE stripPrefix #-}
351355stripPrefix
352356 :: (Monad m, Eq a)
core/src/Streamly/Internal/Data/Stream/Enumerate.hs+20−20
@@ -92,7 +92,7 @@ import qualified Streamly.Internal.Data.Stream.StreamD.Generate as D
9292--
9393-- @
9494--
95−-- @since 0.6.0
95+-- @since 0.9.0
9696{-# INLINE enumerateFromStepIntegral #-}
9797enumerateFromStepIntegral
9898 :: (Monad m, Integral a)
@@ -110,7 +110,7 @@ enumerateFromStepIntegral from stride =
110110--
111111-- @
112112--
113−-- @since 0.6.0
113+-- @since 0.9.0
114114{-# INLINE enumerateFromIntegral #-}
115115enumerateFromIntegral
116116 :: (Monad m, Integral a, Bounded a)
@@ -131,7 +131,7 @@ enumerateFromIntegral from = fromStreamD $ D.enumerateFromIntegral from
131131--
132132-- @
133133--
134−-- @since 0.6.0
134+-- @since 0.9.0
135135{-# INLINE enumerateFromThenIntegral #-}
136136enumerateFromThenIntegral
137137 :: (Monad m, Integral a, Bounded a)
@@ -150,7 +150,7 @@ enumerateFromThenIntegral from next =
150150--
151151-- @
152152--
153−-- @since 0.6.0
153+-- @since 0.9.0
154154{-# INLINE enumerateFromToIntegral #-}
155155enumerateFromToIntegral :: (Monad m, Integral a) => a -> a -> Stream m a
156156enumerateFromToIntegral from to =
@@ -170,7 +170,7 @@ enumerateFromToIntegral from to =
170170--
171171-- @
172172--
173−-- @since 0.6.0
173+-- @since 0.9.0
174174{-# INLINE enumerateFromThenToIntegral #-}
175175enumerateFromThenToIntegral
176176 :: (Monad m, Integral a)
@@ -201,7 +201,7 @@ enumerateFromThenToIntegral from next to =
201201-- @
202202--
203203--
204−-- @since 0.6.0
204+-- @since 0.9.0
205205{-# INLINE enumerateFromFractional #-}
206206enumerateFromFractional :: (Monad m, Fractional a) => a -> Stream m a
207207enumerateFromFractional from = fromStreamD $ D.enumerateFromNum from
@@ -224,7 +224,7 @@ enumerateFromFractional from = fromStreamD $ D.enumerateFromNum from
224224--
225225-- @
226226--
227−-- @since 0.6.0
227+-- @since 0.9.0
228228{-# INLINE enumerateFromThenFractional #-}
229229enumerateFromThenFractional
230230 :: (Monad m, Fractional a)
@@ -251,7 +251,7 @@ enumerateFromThenFractional from next = fromStreamD $ D.enumerateFromThenNum fro
251251-- Notice that the last element is equal to the specified @to@ value after
252252-- rounding to the nearest integer.
253253--
254−-- @since 0.6.0
254+-- @since 0.9.0
255255{-# INLINE enumerateFromToFractional #-}
256256enumerateFromToFractional
257257 :: (Monad m, Fractional a, Ord a)
@@ -277,7 +277,7 @@ enumerateFromToFractional from to =
277277-- @
278278--
279279--
280−-- @since 0.6.0
280+-- @since 0.9.0
281281{-# INLINE enumerateFromThenToFractional #-}
282282enumerateFromThenToFractional
283283 :: (Monad m, Fractional a, Ord a)
@@ -291,7 +291,7 @@ enumerateFromThenToFractional from next to =
291291--
292292-- | 'enumerateFromTo' for 'Enum' types not larger than 'Int'.
293293--
294−-- @since 0.6.0
294+-- @since 0.9.0
295295{-# INLINE enumerateFromToSmall #-}
296296enumerateFromToSmall :: (Monad m, Enum a) => a -> a -> Stream m a
297297enumerateFromToSmall from to =
@@ -300,7 +300,7 @@ enumerateFromToSmall from to =
300300
301301-- | 'enumerateFromThenTo' for 'Enum' types not larger than 'Int'.
302302--
303−-- @since 0.6.0
303+-- @since 0.9.0
304304{-# INLINE enumerateFromThenToSmall #-}
305305enumerateFromThenToSmall :: (Monad m, Enum a)
306306 => a -> a -> a -> Stream m a
@@ -317,7 +317,7 @@ enumerateFromThenToSmall from next to =
317317-- of 'toEnum' when converting back to 'Enum'. Therefore we require a 'Bounded'
318318-- instance for this function to be safely used.
319319--
320−-- @since 0.6.0
320+-- @since 0.9.0
321321{-# INLINE enumerateFromThenSmallBounded #-}
322322enumerateFromThenSmallBounded :: (Monad m, Enumerable a, Bounded a)
323323 => a -> a -> Stream m a
@@ -344,7 +344,7 @@ enumerateFromThenSmallBounded from next =
344344-- generate a stream instead of a list. Use the functions in
345345-- "Streamly.Internal.Data.Stream.Enumeration" module to define new instances.
346346--
347−-- @since 0.6.0
347+-- @since 0.9.0
348348class Enum a => Enumerable a where
349349 -- | @enumerateFrom from@ generates a stream starting with the element
350350 -- @from@, enumerating up to 'maxBound' when the type is 'Bounded' or
@@ -365,7 +365,7 @@ class Enum a => Enumerable a where
365365 --
366366 -- @
367367 --
368− -- @since 0.6.0
368+ -- @since 0.9.0
369369 enumerateFrom :: (Monad m) => a -> Stream m a
370370
371371 -- | Generate a finite stream starting with the element @from@, enumerating
@@ -390,7 +390,7 @@ class Enum a => Enumerable a where
390390 --
391391 -- @
392392 --
393− -- @since 0.6.0
393+ -- @since 0.9.0
394394 enumerateFromTo :: (Monad m) => a -> a -> Stream m a
395395
396396 -- | @enumerateFromThen from then@ generates a stream whose first element
@@ -409,7 +409,7 @@ class Enum a => Enumerable a where
409409 --
410410 -- @
411411 --
412− -- @since 0.6.0
412+ -- @since 0.9.0
413413 enumerateFromThen :: (Monad m) => a -> a -> Stream m a
414414
415415 -- | @enumerateFromThenTo from then to@ generates a finite stream whose
@@ -427,7 +427,7 @@ class Enum a => Enumerable a where
427427 --
428428 -- @
429429 --
430− -- @since 0.6.0
430+ -- @since 0.9.0
431431 enumerateFromThenTo :: (Monad m) => a -> a -> a -> Stream m a
432432
433433-- MAYBE: Sometimes it is more convenient to know the count rather then the
@@ -450,7 +450,7 @@ class Enum a => Enumerable a where
450450--
451451-- Enumerate a 'Bounded' type from its 'minBound' to 'maxBound'
452452--
453−-- @since 0.6.0
453+-- @since 0.9.0
454454{-# INLINE enumerate #-}
455455enumerate :: (Monad m, Bounded a, Enumerable a) => Stream m a
456456enumerate = enumerateFrom minBound
@@ -460,7 +460,7 @@ enumerate = enumerateFrom minBound
460460--
461461-- Enumerate a 'Bounded' type from its 'minBound' to specified value.
462462--
463−-- @since 0.6.0
463+-- @since 0.9.0
464464{-# INLINE enumerateTo #-}
465465enumerateTo :: (Monad m, Bounded a, Enumerable a) => a -> Stream m a
466466enumerateTo = enumerateFromTo minBound
@@ -470,7 +470,7 @@ enumerateTo = enumerateFromTo minBound
470470--
471471-- 'enumerateFrom' for 'Bounded' 'Enum' types.
472472--
473−-- @since 0.6.0
473+-- @since 0.9.0
474474{-# INLINE enumerateFromBounded #-}
475475enumerateFromBounded :: (Monad m, Enumerable a, Bounded a)
476476 => a -> Stream m a
core/src/Streamly/Internal/Data/Stream/Exception.hs+6
@@ -46,6 +46,7 @@ import qualified Streamly.Internal.Data.Stream.StreamD as D
4646-- >>> before action xs = Stream.nilM action <> xs
4747-- >>> before action xs = Stream.concatMap (const xs) (Stream.fromEffect action)
4848--
49+-- @since 0.9.0
4950{-# INLINE before #-}
5051before :: Monad m => m b -> Stream m a -> Stream m a
5152before action xs = fromStreamD $ D.before action $ toStreamD xs
@@ -75,6 +76,7 @@ after_ action xs = fromStreamD $ D.after_ action $ toStreamD xs
7576--
7677-- /See also 'after_'/
7778--
79+-- @since 0.9.0
7880{-# INLINE after #-}
7981after :: MonadAsync m
8082 => m b -> Stream m a -> Stream m a
@@ -85,6 +87,7 @@ after action xs = fromStreamD $ D.after action $ toStreamD xs
8587--
8688-- /Inhibits stream fusion/
8789--
90+-- @since 0.9.0
8891{-# INLINE onException #-}
8992onException :: MonadCatch m => m b -> Stream m a -> Stream m a
9093onException action xs = fromStreamD $ D.onException action $ toStreamD xs
@@ -117,6 +120,7 @@ finally_ action xs = fromStreamD $ D.finally_ action $ toStreamD xs
117120--
118121-- /Inhibits stream fusion/
119122--
123+-- @since 0.9.0
120124{-# INLINE finally #-}
121125finally :: (MonadAsync m, MonadCatch m) => m b -> Stream m a -> Stream m a
122126finally action xs = fromStreamD $ D.finally action $ toStreamD xs
@@ -160,6 +164,7 @@ bracket_ bef aft bet = fromStreamD $
160164--
161165-- /Inhibits stream fusion/
162166--
167+-- @since 0.9.0
163168{-# INLINE bracket #-}
164169bracket :: (MonadAsync m, MonadCatch m)
165170 => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a
@@ -212,6 +217,7 @@ ghandle handler =
212217--
213218-- /Inhibits stream fusion/
214219--
220+-- @since 0.9.0
215221{-# INLINE handle #-}
216222handle :: (MonadCatch m, Exception e)
217223 => (e -> Stream m a) -> Stream m a -> Stream m a
core/src/Streamly/Internal/Data/Stream/Expand.hs+9−3
@@ -163,7 +163,7 @@ infixr 6 `append2`
163163--
164164-- /Fused/
165165--
166−-- /Pre-release/
166+-- @since 0.9.0
167167{-# INLINE append2 #-}
168168append2 ::Monad m => Stream m b -> Stream m b -> Stream m b
169169append2 m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
@@ -184,8 +184,7 @@ infixr 6 `append`
184184--
185185-- /Not fused/
186186--
187−-- /Pre-release/
188−--
187+-- @since 0.9.0
189188{-# INLINE append #-}
190189append :: Stream m a -> Stream m a -> Stream m a
191190append = (<>)
@@ -204,6 +203,8 @@ append = (<>)
204203-- streams.
205204--
206205-- /Not fused/
206+--
207+-- @since 0.9.0
207208{-# INLINE interleave #-}
208209interleave :: Stream m a -> Stream m a -> Stream m a
209210interleave s1 s2 = fromStreamK $ K.interleave (toStreamK s1) (toStreamK s2)
@@ -245,6 +246,7 @@ interleaveMin s1 s2 =
245246--
246247-- See also: 'mergeByM2'
247248--
249+-- @since 0.9.0
248250{-# INLINE mergeBy #-}
249251mergeBy :: (a -> a -> Ordering) -> Stream m a -> Stream m a -> Stream m a
250252mergeBy f m1 m2 = fromStreamK $ K.mergeBy f (toStreamK m1) (toStreamK m2)
@@ -279,6 +281,7 @@ mergeBy f m1 m2 = fromStreamK $ K.mergeBy f (toStreamK m1) (toStreamK m2)
279281--
280282-- See also: 'mergeByM2'
281283--
284+-- @since 0.9.0
282285{-# INLINE mergeByM #-}
283286mergeByM
284287 :: Monad m
@@ -324,6 +327,7 @@ mergeFstBy _f _m1 _m2 = undefined
324327-- 'concatMap' this can fuse the 'Unfold' code with the inner loop and
325328-- therefore provide many times better performance.
326329--
330+-- @since 0.9.0
327331{-# INLINE unfoldMany #-}
328332unfoldMany ::Monad m => Unfold m a b -> Stream m a -> Stream m b
329333unfoldMany u m = fromStreamD $ D.unfoldMany u (toStreamD m)
@@ -427,6 +431,7 @@ gintercalate unf1 str1 unf2 str2 =
427431-- >>> Stream.fold Fold.toList $ Stream.intercalate Unfold.fromList " " input
428432-- "abc def ghi"
429433--
434+-- @since 0.9.0
430435{-# INLINE intercalate #-}
431436intercalate :: Monad m
432437 => Unfold m b c -> b -> Stream m b -> Stream m c
@@ -457,6 +462,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
457462-- >>> Stream.fold Fold.toList $ Stream.intercalateSuffix Unfold.fromList "\n" input
458463-- "abc\ndef\nghi\n"
459464--
465+-- @since 0.9.0
460466{-# INLINE intercalateSuffix #-}
461467intercalateSuffix :: Monad m
462468 => Unfold m b c -> b -> Stream m b -> Stream m c
core/src/Streamly/Internal/Data/Stream/Generate.hs+8−2
@@ -118,7 +118,7 @@ import Prelude hiding (iterate, replicate, repeat)
118118-- hello
119119-- hello
120120--
121−-- /Pre-release/
121+-- @since 0.9.0
122122{-# INLINE unfold #-}
123123unfold :: Monad m => Unfold m a b -> a -> Stream m b
124124unfold unf = Stream.fromStreamD . D.unfold unf
@@ -149,6 +149,7 @@ unfold unf = Stream.fromStreamD . D.unfold unf
149149-- :}
150150-- [0,1,2]
151151--
152+-- @since 0.9.0
152153{-# INLINE_EARLY unfoldr #-}
153154unfoldr :: Monad m => (b -> Maybe (a, b)) -> b -> Stream m a
154155unfoldr step seed = fromStreamD (D.unfoldr step seed)
@@ -169,7 +170,7 @@ unfoldr step seed = fromStreamD (D.unfoldr step seed)
169170-- :}
170171-- [0,1,2]
171172--
172−--
173+-- @since 0.9.0
173174{-# INLINE unfoldrM #-}
174175unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> Stream m a
175176unfoldrM step = fromStreamD . D.unfoldrM step
@@ -181,6 +182,7 @@ unfoldrM step = fromStreamD . D.unfoldrM step
181182-- |
182183-- Generate an infinite stream by repeating a pure value.
183184--
185+-- @since 0.9.0
184186{-# INLINE_NORMAL repeat #-}
185187repeat :: Monad m => a -> Stream m a
186188repeat = fromStreamD . D.repeat
@@ -190,6 +192,7 @@ repeat = fromStreamD . D.repeat
190192--
191193-- Generate a stream of length @n@ by repeating a value @n@ times.
192194--
195+-- @since 0.9.0
193196{-# INLINE_NORMAL replicate #-}
194197replicate :: Monad m => Int -> a -> Stream m a
195198replicate n = fromStreamD . D.replicate n
@@ -293,6 +296,7 @@ timeout = undefined
293296-- >>> Stream.fold Fold.toList $ Stream.take 5 $ Stream.iterate (+1) 1
294297-- [1,2,3,4,5]
295298--
299+-- @since 0.9.0
296300{-# INLINE_NORMAL iterate #-}
297301iterate :: Monad m => (a -> a) -> a -> Stream m a
298302iterate step = fromStreamD . D.iterate step
@@ -313,6 +317,7 @@ iterate step = fromStreamD . D.iterate step
313317-- 1
314318-- [0,1,2]
315319--
320+-- @since 0.9.0
316321{-# INLINE iterateM #-}
317322iterateM :: Monad m => (a -> m a) -> m a -> Stream m a
318323iterateM step = fromStreamD . D.iterateM step
@@ -385,6 +390,7 @@ mfix f = fromStreamK $ K.mfix (toStreamK . f)
385390--
386391-- /Not fused/
387392--
393+-- @since 0.9.0
388394{-# INLINE fromFoldable #-}
389395fromFoldable :: Foldable f => f a -> Stream m a
390396fromFoldable = fromStreamK . K.fromFoldable
core/src/Streamly/Internal/Data/Stream/Lift.hs+3
@@ -66,6 +66,7 @@ generally xs = fromStreamK $ K.hoist (return . runIdentity) (toStreamK xs)
6666-- | Lift the inner monad @m@ of a stream @Stream m a@ to @tr m@ using the monad
6767-- transformer @tr@.
6868--
69+-- @since 0.9.0
6970{-# INLINE liftInner #-}
7071liftInner :: (Monad m, MonadTrans tr, Monad (tr m))
7172 => Stream m a -> Stream (tr m) a
@@ -77,6 +78,7 @@ liftInner xs = fromStreamD $ D.liftInner (toStreamD xs)
7778
7879-- | Evaluate the inner monad of a stream as 'ReaderT'.
7980--
81+-- @since 0.9.0
8082{-# INLINE runReaderT #-}
8183runReaderT :: Monad m => m s -> Stream (ReaderT s m) a -> Stream m a
8284runReaderT s xs = fromStreamD $ D.runReaderT s (toStreamD xs)
@@ -131,6 +133,7 @@ usingStateT s f = evalStateT s . f . liftInner
131133-- | Evaluate the inner monad of a stream as 'StateT' and emit the resulting
132134-- state and value pair after each step.
133135--
136+-- @since 0.9.0
134137{-# INLINE runStateT #-}
135138runStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m (s, a)
136139runStateT s xs = fromStreamD $ D.runStateT s (toStreamD xs)
core/src/Streamly/Internal/Data/Stream/Reduce.hs+1
@@ -145,6 +145,7 @@ dropSuffix = error "Not implemented yet!"
145145-- Note 'foldMany' on an empty stream results in an empty stream. Therefore,
146146-- @Stream.fold f@ is not the same as @Stream.head . Stream.foldMany f@.
147147--
148+-- @since 0.9.0
148149{-# INLINE foldMany #-}
149150foldMany
150151 :: Monad m
core/src/Streamly/Internal/Data/Stream/Transform.hs+21−3
@@ -265,8 +265,7 @@ foldrT f z s = D.foldrT f z (toStreamD s)
265265-- >>> Stream.fold Fold.drain $ Stream.mapM putStr s
266266-- abc
267267--
268−-- /Pre-release/
269−--
268+-- @since 0.9.0
270269{-# INLINE mapM #-}
271270mapM :: Monad m => (a -> m b) -> Stream m a -> Stream m b
272271mapM f m = fromStreamK $ D.toStreamK $ D.mapM f $ toStreamD m
@@ -281,6 +280,7 @@ mapM f m = fromStreamK $ D.toStreamK $ D.mapM f $ toStreamD m
281280-- >>> Stream.fold Fold.drain $ Stream.sequence s
282281-- abc
283282--
283+-- @since 0.9.0
284284{-# INLINE sequence #-}
285285sequence :: Monad m => Stream m (m a) -> Stream m a
286286sequence = mapM id
@@ -307,6 +307,7 @@ sequence = mapM id
307307--
308308-- Compare with 'trace'.
309309--
310+-- @since 0.9.0
310311{-# INLINE tap #-}
311312tap :: Monad m => FL.Fold m a b -> Stream m a -> Stream m a
312313tap f xs = fromStreamD $ D.tap f (toStreamD xs)
@@ -363,6 +364,7 @@ trace_ eff = fromStreamD . D.mapM (\x -> eff >> return x) . toStreamD
363364--
364365-- See also: 'usingStateT'
365366--
367+-- @since 0.9.0
366368
367369-- EXPLANATION:
368370-- >>> scanl' step z = Stream.scan (Fold.foldl' step z)
@@ -407,6 +409,7 @@ trace_ eff = fromStreamD . D.mapM (\x -> eff >> return x) . toStreamD
407409-- lazy expressions inside the accumulator, it is recommended that a strict
408410-- data structure is used for accumulator.
409411--
412+-- @since 0.9.0
410413{-# INLINE scan #-}
411414scan :: Monad m => Fold m a b -> Stream m a -> Stream m b
412415scan fld m = fromStreamD $ D.scanOnce fld $ toStreamD m
@@ -414,7 +417,7 @@ scan fld m = fromStreamD $ D.scanOnce fld $ toStreamD m
414417-- | Like 'scan' but restarts scanning afresh when the scanning fold
415418-- terminates.
416419--
417−-- /Pre-release/
420+-- @since 0.9.0
418421{-# INLINE scanMany #-}
419422scanMany :: Monad m => Fold m a b -> Stream m a -> Stream m b
420423scanMany fld m = fromStreamD $ D.scanMany fld $ toStreamD m
@@ -444,6 +447,7 @@ with f comb g = fmap snd . comb g . f
444447-- >>> filter p = Stream.mapMaybe (\x -> if p x then Just x else Nothing)
445448-- >>> filter p = Stream.scanMaybe (Fold.filtering p)
446449--
450+-- @since 0.9.0
447451{-# INLINE filter #-}
448452filter :: Monad m => (a -> Bool) -> Stream m a -> Stream m a
449453-- filter p = scanMaybe (FL.filtering p)
@@ -454,6 +458,7 @@ filter p m = fromStreamD $ D.filter p $ toStreamD m
454458-- >>> f p x = p x >>= \r -> return $ if r then Just x else Nothing
455459-- >>> filterM p = Stream.mapMaybeM (f p)
456460--
461+-- @since 0.9.0
457462{-# INLINE filterM #-}
458463filterM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a
459464filterM p m = fromStreamD $ D.filterM p $ toStreamD m
@@ -493,6 +498,7 @@ uniqBy eq = catMaybes . rollingMap f
493498--
494499-- >>> uniq = Stream.uniqBy (==)
495500--
501+-- @since 0.9.0
496502{-# INLINE uniq #-}
497503uniq :: (Eq a, Monad m) => Stream m a -> Stream m a
498504-- uniq = scanMaybe FL.uniq
@@ -539,6 +545,7 @@ repeated = undefined
539545-- >>> Stream.fold Fold.toList $ Stream.deleteBy (==) 3 input
540546-- [1,3,5]
541547--
548+-- @since 0.9.0
542549{-# INLINE deleteBy #-}
543550deleteBy :: Monad m => (a -> a -> Bool) -> a -> Stream m a -> Stream m a
544551-- deleteBy cmp x = scanMaybe (FL.deleteBy cmp x)
@@ -550,6 +557,7 @@ deleteBy cmp x m = fromStreamD $ D.deleteBy cmp x (toStreamD m)
550557
551558-- | Same as 'takeWhile' but with a monadic predicate.
552559--
560+-- @since 0.9.0
553561{-# INLINE takeWhileM #-}
554562takeWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a
555563-- takeWhileM p = scanMaybe (FL.takingEndByM_ (\x -> not <$> p x))
@@ -558,6 +566,7 @@ takeWhileM p m = fromStreamD $ D.takeWhileM p $ toStreamD m
558566-- | Drop elements in the stream as long as the predicate succeeds and then
559567-- take the rest of the stream.
560568--
569+-- @since 0.9.0
561570{-# INLINE dropWhile #-}
562571dropWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a
563572-- dropWhile p = scanMaybe (FL.droppingWhile p)
@@ -565,6 +574,7 @@ dropWhile p m = fromStreamD $ D.dropWhile p $ toStreamD m
565574
566575-- | Same as 'dropWhile' but with a monadic predicate.
567576--
577+-- @since 0.9.0
568578{-# INLINE dropWhileM #-}
569579dropWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a
570580-- dropWhileM p = scanMaybe (FL.droppingWhileM p)
@@ -583,6 +593,7 @@ dropWhileM p m = fromStreamD $ D.dropWhileM p $ toStreamD m
583593-- >>> Stream.fold Fold.toList $ Stream.insertBy compare 2 input
584594-- [1,2,3,5]
585595--
596+-- @since 0.9.0
586597{-# INLINE insertBy #-}
587598insertBy ::Monad m => (a -> a -> Ordering) -> a -> Stream m a -> Stream m a
588599insertBy cmp x m = fromStreamD $ D.insertBy cmp x (toStreamD m)
@@ -593,6 +604,7 @@ insertBy cmp x m = fromStreamD $ D.insertBy cmp x (toStreamD m)
593604-- >>> Stream.fold Fold.toList $ Stream.intersperse ',' input
594605-- "h,e,l,l,o"
595606--
607+-- @since 0.9.0
596608{-# INLINE intersperse #-}
597609intersperse :: Monad m => a -> Stream m a -> Stream m a
598610intersperse a = fromStreamD . D.intersperse a . toStreamD
@@ -691,6 +703,7 @@ interspersePrefix_ m = mapM (\x -> void m >> return x)
691703-- >>> sleep n = liftIO $ threadDelay $ round $ n * 1000000
692704-- >>> delay n = Stream.intersperseM_ $ sleep n
693705--
706+-- @since 0.9.0
694707{-# INLINE delay #-}
695708delay :: MonadIO m => Double -> Stream m a -> Stream m a
696709delay n = intersperseM_ $ liftIO $ threadDelay $ round $ n * 1000000
@@ -758,6 +771,7 @@ reassembleBy = undefined
758771-- >>> Stream.fold Fold.toList $ Stream.indexed $ Stream.fromList "hello"
759772-- [(0,'h'),(1,'e'),(2,'l'),(3,'l'),(4,'o')]
760773--
774+-- @since 0.9.0
761775{-# INLINE indexed #-}
762776indexed :: Monad m => Stream m a -> Stream m (Int, a)
763777-- indexed = scanMaybe FL.indexing
@@ -776,6 +790,7 @@ indexed = fromStreamD . D.indexed . toStreamD
776790-- >>> Stream.fold Fold.toList $ Stream.indexedR 10 $ Stream.fromList "hello"
777791-- [(10,'h'),(9,'e'),(8,'l'),(7,'l'),(6,'o')]
778792--
793+-- @since 0.9.0
779794{-# INLINE indexedR #-}
780795indexedR :: Monad m => Int -> Stream m a -> Stream m (Int, a)
781796-- indexedR n = scanMaybe (FL.indexingRev n)
@@ -790,6 +805,7 @@ indexedR n = fromStreamD . D.indexedR n . toStreamD
790805--
791806-- >>> elemIndices a = Stream.findIndices (== a)
792807--
808+-- @since 0.9.0
793809{-# INLINE elemIndices #-}
794810elemIndices :: (Monad m, Eq a) => a -> Stream m a -> Stream m Int
795811elemIndices a = findIndices (== a)
@@ -844,6 +860,7 @@ rollingMap2 f m = fromStreamD $ D.rollingMap2 f $ toStreamD m
844860--
845861-- >>> mapMaybe f = Stream.catMaybes . fmap f
846862--
863+-- @since 0.9.0
847864{-# INLINE mapMaybe #-}
848865mapMaybe :: Monad m => (a -> Maybe b) -> Stream m a -> Stream m b
849866mapMaybe f m = fromStreamD $ D.mapMaybe f $ toStreamD m
@@ -856,6 +873,7 @@ mapMaybe f m = fromStreamD $ D.mapMaybe f $ toStreamD m
856873--
857874-- >>> mapM f = Stream.mapMaybeM (\x -> Just <$> f x)
858875--
876+-- @since 0.9.0
859877{-# INLINE_EARLY mapMaybeM #-}
860878mapMaybeM :: Monad m
861879 => (a -> m (Maybe b)) -> Stream m a -> Stream m b
core/src/Streamly/Internal/Data/Stream/Type.hs+4
@@ -470,6 +470,7 @@ consM m = fromStreamK . K.consM m . toStreamK
470470-- >>> Stream.fold Fold.toList Stream.nil
471471-- []
472472--
473+-- @since 0.9.0
473474{-# INLINE_NORMAL nil #-}
474475nil :: Stream m a
475476nil = fromStreamK K.nil
@@ -491,6 +492,7 @@ nilM = fromStreamK . K.nilM
491492-- >>> fromPure = pure
492493-- >>> fromPure = fromEffect . pure
493494--
495+-- @since 0.9.0
494496{-# INLINE_NORMAL fromPure #-}
495497fromPure :: a -> Stream m a
496498fromPure = fromStreamK . K.fromPure
@@ -503,6 +505,7 @@ fromPure = fromStreamK . K.fromPure
503505-- >>> Stream.fold Fold.drain $ Stream.fromEffect (putStrLn "hello")
504506-- hello
505507--
508+-- @since 0.9.0
506509{-# INLINE_NORMAL fromEffect #-}
507510fromEffect :: Monad m => m a -> Stream m a
508511fromEffect = fromStreamK . K.fromEffect
@@ -531,6 +534,7 @@ bindWith par m1 f =
531534--
532535-- Note we can merge streams concurrently by using a concurrent merge function.
533536--
537+-- @since 0.9.0
534538{-# INLINE concatMapWith #-}
535539concatMapWith
536540 :: (Stream m b -> Stream m b -> Stream m b)