on master help sign in
Add Since: 0.8.0 annotations to new functions.
16dfa56Pranay Sashank
src/Streamly/Internal/Data/Stream/Async.hs+1−2
@@ -515,7 +515,6 @@ mkAsyncD m = D.Stream step Nothing
515 D.Skip s -> D.Skip (Just $ D.Stream step1 s)
515 D.Skip s -> D.Skip (Just $ D.Stream step1 s)
516 D.Stop -> D.Stop
516 D.Stop -> D.Stop
517
517
518−-- /Since: 0.8.0 ("Streamly.Prelude")/
519--
518--
520-- This is slightly faster than the CPS version above
519-- This is slightly faster than the CPS version above
521--
520--
@@ -525,7 +524,7 @@ mkAsyncD m = D.Stream step Nothing
525-- kicked off again to evaluate the remaining stream when there is space in the
524-- kicked off again to evaluate the remaining stream when there is space in the
526-- buffer. The consumer consumes the stream lazily from the buffer.
525-- buffer. The consumer consumes the stream lazily from the buffer.
527--
526--
528−-- /Pre-release/
527+-- /Since: 0.8.0/
529--
528--
530{-# INLINE_NORMAL mkAsync #-}
529{-# INLINE_NORMAL mkAsync #-}
531mkAsync :: (K.IsStream t, MonadAsync m) => t m a -> t m a
530mkAsync :: (K.IsStream t, MonadAsync m) => t m a -> t m a
src/Streamly/Internal/Data/Unfold.hs+39−8
@@ -266,7 +266,7 @@ import Prelude
266-- lmapM f = Unfold.many (Unfold.functionM f)
266-- lmapM f = Unfold.many (Unfold.functionM f)
267-- @
267-- @
268--
268--
269−-- /Pre-release/
269+-- /Since: 0.8.0/
270{-# INLINE_NORMAL lmapM #-}
270{-# INLINE_NORMAL lmapM #-}
271lmapM :: Monad m => (a -> m c) -> Unfold m c b -> Unfold m a b
271lmapM :: Monad m => (a -> m c) -> Unfold m c b -> Unfold m a b
272lmapM f (Unfold ustep uinject) = Unfold ustep (f >=> uinject)
272lmapM f (Unfold ustep uinject) = Unfold ustep (f >=> uinject)
@@ -387,6 +387,11 @@ fold (Fold fstep initial extract) (Unfold ustep inject) a = do
387 Skip s -> go SPEC fs s
387 Skip s -> go SPEC fs s
388 Stop -> extract fs
388 Stop -> extract fs
389
389
390+-- | Apply a monadic function to each element of the stream and replace it
391+-- with the output of the resulting action.
392+--
393+-- /Since: 0.8.0/
394+--
390{-# INLINE_NORMAL mapM #-}
395{-# INLINE_NORMAL mapM #-}
391mapM :: Monad m => (b -> m c) -> Unfold m a b -> Unfold m a c
396mapM :: Monad m => (b -> m c) -> Unfold m a b -> Unfold m a c
392mapM f (Unfold ustep uinject) = Unfold step uinject
397mapM f (Unfold ustep uinject) = Unfold step uinject
@@ -449,7 +454,8 @@ fromStreamK = Unfold step return
449-- | Convert a stream into an 'Unfold'. Note that a stream converted to an
454-- | Convert a stream into an 'Unfold'. Note that a stream converted to an
450-- 'Unfold' may not be as efficient as an 'Unfold' in some situations.
455-- 'Unfold' may not be as efficient as an 'Unfold' in some situations.
451--
456--
452−-- /Pre-release/
457+-- /Since: 0.8.0/
458+--
453{-# INLINE_NORMAL fromStream #-}
459{-# INLINE_NORMAL fromStream #-}
454fromStream :: (K.IsStream t, Monad m) => Unfold m (t m a) a
460fromStream :: (K.IsStream t, Monad m) => Unfold m (t m a) a
455fromStream = lmap K.toStream fromStreamK
461fromStream = lmap K.toStream fromStreamK
@@ -491,6 +497,9 @@ consM action unf = Unfold step inject
491 Stop -> return Stop
497 Stop -> return Stop
492
498
493-- | Convert a list of pure values to a 'Stream'
499-- | Convert a list of pure values to a 'Stream'
500+--
501+-- /Since: 0.8.0/
502+--
494{-# INLINE_LATE fromList #-}
503{-# INLINE_LATE fromList #-}
495fromList :: Monad m => Unfold m [a] a
504fromList :: Monad m => Unfold m [a] a
496fromList = Unfold step inject
505fromList = Unfold step inject
@@ -501,6 +510,9 @@ fromList = Unfold step inject
501 step [] = return Stop
510 step [] = return Stop
502
511
503-- | Convert a list of monadic values to a 'Stream'
512-- | Convert a list of monadic values to a 'Stream'
513+--
514+-- /Since: 0.8.0/
515+--
504{-# INLINE_LATE fromListM #-}
516{-# INLINE_LATE fromListM #-}
505fromListM :: Monad m => Unfold m [m a] a
517fromListM :: Monad m => Unfold m [m a] a
506fromListM = Unfold step inject
518fromListM = Unfold step inject
@@ -516,7 +528,7 @@ fromListM = Unfold step inject
516
528
517-- | Generates a stream replicating the seed @n@ times.
529-- | Generates a stream replicating the seed @n@ times.
518--
530--
519−-- /Pre-release/
531+-- /Since: 0.8.0/
520--
532--
521{-# INLINE replicateM #-}
533{-# INLINE replicateM #-}
522replicateM :: Monad m => Int -> Unfold m (m a) a
534replicateM :: Monad m => Int -> Unfold m (m a) a
@@ -536,7 +548,7 @@ replicateM n = Unfold step inject
536
548
537-- | Generates an infinite stream repeating the seed.
549-- | Generates an infinite stream repeating the seed.
538--
550--
539−-- /Pre-release/
551+-- /Since: 0.8.0/
540--
552--
541{-# INLINE repeatM #-}
553{-# INLINE repeatM #-}
542repeatM :: Monad m => Unfold m (m a) a
554repeatM :: Monad m => Unfold m (m a) a
@@ -548,7 +560,7 @@ repeatM = Unfold step return
548-- | Generates an infinite stream starting with the given seed and applying the
560-- | Generates an infinite stream starting with the given seed and applying the
549-- given function repeatedly.
561-- given function repeatedly.
550--
562--
551−-- /Pre-release/
563+-- /Since: 0.8.0/
552--
564--
553{-# INLINE iterateM #-}
565{-# INLINE iterateM #-}
554iterateM :: Monad m => (a -> m a) -> Unfold m (m a) a
566iterateM :: Monad m => (a -> m a) -> Unfold m (m a) a
@@ -586,6 +598,8 @@ fromIndicesM gen = Unfold step return
586-- >>> Unfold.fold Fold.toList u [1..100]
598-- >>> Unfold.fold Fold.toList u [1..100]
587-- [1,2]
599-- [1,2]
588--
600--
601+-- /Since: 0.8.0/
602+--
589{-# INLINE_NORMAL take #-}
603{-# INLINE_NORMAL take #-}
590take :: Monad m => Int -> Unfold m a b -> Unfold m a b
604take :: Monad m => Int -> Unfold m a b -> Unfold m a b
591take n (Unfold step1 inject1) = Unfold step inject
605take n (Unfold step1 inject1) = Unfold step inject
@@ -602,6 +616,10 @@ take n (Unfold step1 inject1) = Unfold step inject
602 Stop -> Stop
616 Stop -> Stop
603 step (_, _) = return Stop
617 step (_, _) = return Stop
604
618
619+-- | Same as 'takeWhile' but with a monadic predicate.
620+--
621+-- /Since: 0.8.0/
622+--
605{-# INLINE_NORMAL takeWhileM #-}
623{-# INLINE_NORMAL takeWhileM #-}
606takeWhileM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
624takeWhileM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
607takeWhileM f (Unfold step1 inject1) = Unfold step inject1
625takeWhileM f (Unfold step1 inject1) = Unfold step inject1
@@ -616,10 +634,19 @@ takeWhileM f (Unfold step1 inject1) = Unfold step inject1
616 Skip s -> return $ Skip s
634 Skip s -> return $ Skip s
617 Stop -> return Stop
635 Stop -> return Stop
618
636
637+-- | End the stream generated by the 'Unfold' as soon as the predicate fails
638+-- on an element.
639+--
640+-- /Since: 0.8.0/
641+--
619{-# INLINE takeWhile #-}
642{-# INLINE takeWhile #-}
620takeWhile :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
643takeWhile :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
621takeWhile f = takeWhileM (return . f)
644takeWhile f = takeWhileM (return . f)
622
645
646+-- | Same as 'filter' but with a monadic predicate.
647+--
648+-- /Since: 0.8.0/
649+--
623{-# INLINE_NORMAL filterM #-}
650{-# INLINE_NORMAL filterM #-}
624filterM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
651filterM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
625filterM f (Unfold step1 inject1) = Unfold step inject1
652filterM f (Unfold step1 inject1) = Unfold step inject1
@@ -634,13 +661,17 @@ filterM f (Unfold step1 inject1) = Unfold step inject1
634 Skip s -> return $ Skip s
661 Skip s -> return $ Skip s
635 Stop -> return Stop
662 Stop -> return Stop
636
663
664+-- | Include only those elements that pass a predicate.
665+--
666+-- /Since: 0.8.0/
667+--
637{-# INLINE filter #-}
668{-# INLINE filter #-}
638filter :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
669filter :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
639filter f = filterM (return . f)
670filter f = filterM (return . f)
640
671
641-- | @drop n unf@ drops @n@ elements from the stream generated by @unf@.
672-- | @drop n unf@ drops @n@ elements from the stream generated by @unf@.
642--
673--
643−-- /Pre-release/
674+-- /Since: 0.8.0/
644--
675--
645{-# INLINE_NORMAL drop #-}
676{-# INLINE_NORMAL drop #-}
646drop :: Monad m => Int -> Unfold m a b -> Unfold m a b
677drop :: Monad m => Int -> Unfold m a b -> Unfold m a b
@@ -672,7 +703,7 @@ drop n (Unfold step inject) = Unfold step' inject'
672-- | @dropWhileM f unf@ drops elements from the stream generated by @unf@ while
703-- | @dropWhileM f unf@ drops elements from the stream generated by @unf@ while
673-- the condition holds true. The condition function @f@ is /monadic/ in nature.
704-- the condition holds true. The condition function @f@ is /monadic/ in nature.
674--
705--
675−-- /Pre-release/
706+-- /Since: 0.8.0/
676--
707--
677{-# INLINE_NORMAL dropWhileM #-}
708{-# INLINE_NORMAL dropWhileM #-}
678dropWhileM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
709dropWhileM :: Monad m => (b -> m Bool) -> Unfold m a b -> Unfold m a b
@@ -706,7 +737,7 @@ dropWhileM f (Unfold step inject) = Unfold step' inject'
706
737
707-- | Similar to 'dropWhileM' but with a pure condition function.
738-- | Similar to 'dropWhileM' but with a pure condition function.
708--
739--
709−-- /Pre-release/
740+-- /Since: 0.8.0/
710--
741--
711{-# INLINE dropWhile #-}
742{-# INLINE dropWhile #-}
712dropWhile :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
743dropWhile :: Monad m => (b -> Bool) -> Unfold m a b -> Unfold m a b
src/Streamly/Internal/Data/Unfold/Type.hs+11−8
@@ -107,7 +107,7 @@ mkUnfoldrM step = Unfold step pure
107-- The step function returns the next element in the stream and the next seed
107-- The step function returns the next element in the stream and the next seed
108-- value. When it is done it returns 'Nothing' and the stream ends.
108-- value. When it is done it returns 'Nothing' and the stream ends.
109--
109--
110−-- /Pre-release/
110+-- /Since: 0.8.0/
111--
111--
112{-# INLINE unfoldrM #-}
112{-# INLINE unfoldrM #-}
113unfoldrM :: Applicative m => (a -> m (Maybe (b, a))) -> Unfold m a b
113unfoldrM :: Applicative m => (a -> m (Maybe (b, a))) -> Unfold m a b
@@ -129,7 +129,7 @@ unfoldrM next = Unfold step pure
129-- >>> Unfold.fold Fold.toList (Unfold.unfoldr f) [1,2,3]
129-- >>> Unfold.fold Fold.toList (Unfold.unfoldr f) [1,2,3]
130-- [1,2,3]
130-- [1,2,3]
131--
131--
132−-- /Pre-release/
132+-- /Since: 0.8.0/
133--
133--
134{-# INLINE unfoldr #-}
134{-# INLINE unfoldr #-}
135unfoldr :: Applicative m => (a -> Maybe (b, a)) -> Unfold m a b
135unfoldr :: Applicative m => (a -> Maybe (b, a)) -> Unfold m a b
@@ -149,7 +149,7 @@ unfoldr step = unfoldrM (pure . step)
149-- lmap f = Unfold.many (Unfold.function f)
149-- lmap f = Unfold.many (Unfold.function f)
150-- @
150-- @
151--
151--
152−-- /Pre-release/
152+-- /Since: 0.8.0/
153{-# INLINE_NORMAL lmap #-}
153{-# INLINE_NORMAL lmap #-}
154lmap :: (a -> c) -> Unfold m c b -> Unfold m a b
154lmap :: (a -> c) -> Unfold m c b -> Unfold m a b
155lmap f (Unfold ustep uinject) = Unfold ustep (uinject Prelude.. f)
155lmap f (Unfold ustep uinject) = Unfold ustep (uinject Prelude.. f)
@@ -264,7 +264,8 @@ crossWithM f (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
264-- >>> Unfold.fold Fold.toList u ([1,2,3], [4,5,6])
264-- >>> Unfold.fold Fold.toList u ([1,2,3], [4,5,6])
265-- [(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)]
265-- [(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)]
266--
266--
267−-- /Pre-release/
267+-- /Since: 0.8.0/
268+--
268{-# INLINE crossWith #-}
269{-# INLINE crossWith #-}
269crossWith :: Monad m =>
270crossWith :: Monad m =>
270 (b -> c -> d) -> Unfold m a b -> Unfold m a c -> Unfold m a d
271 (b -> c -> d) -> Unfold m a b -> Unfold m a c -> Unfold m a d
@@ -398,7 +399,8 @@ instance Monad m => Monad (Unfold m a) where
398-- | Lift a monadic function into an unfold. The unfold generates a singleton
399-- | Lift a monadic function into an unfold. The unfold generates a singleton
399-- stream.
400-- stream.
400--
401--
401−-- /Pre-release/
402+-- /Since: 0.8.0/
403+
402{-# INLINE functionM #-}
404{-# INLINE functionM #-}
403functionM :: Applicative m => (a -> m b) -> Unfold m a b
405functionM :: Applicative m => (a -> m b) -> Unfold m a b
404functionM f = Unfold step inject
406functionM f = Unfold step inject
@@ -416,7 +418,8 @@ functionM f = Unfold step inject
416--
418--
417-- > function f = functionM $ return . f
419-- > function f = functionM $ return . f
418--
420--
419−-- /Pre-release/
421+-- /Since: 0.8.0/
422+
420{-# INLINE function #-}
423{-# INLINE function #-}
421function :: Applicative m => (a -> b) -> Unfold m a b
424function :: Applicative m => (a -> b) -> Unfold m a b
422function f = functionM $ pure Prelude.. f
425function f = functionM $ pure Prelude.. f
@@ -437,7 +440,7 @@ data ConcatState s1 s2 = ConcatOuter s1 | ConcatInner s1 s2
437-- | Apply the second unfold to each output element of the first unfold and
440-- | Apply the second unfold to each output element of the first unfold and
438-- flatten the output in a single stream.
441-- flatten the output in a single stream.
439--
442--
440−-- /Pre-release/
443+-- /Since: 0.8.0/
441--
444--
442{-# INLINE_NORMAL many #-}
445{-# INLINE_NORMAL many #-}
443many :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
446many :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
@@ -530,7 +533,7 @@ zipWithM f (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
530--
533--
531-- > zipWith f = zipWithM (\a b -> return $ f a b)
534-- > zipWith f = zipWithM (\a b -> return $ f a b)
532--
535--
533−-- /Pre-release/
536+-- /Since: 0.8.0/
534--
537--
535{-# INLINE zipWith #-}
538{-# INLINE zipWith #-}
536zipWith :: Monad m
539zipWith :: Monad m