on master help sign in
Add since notations
commit844e31ee3aa313d17d4bb0456e2438289c1f4481 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 16 Aug 2018, 19:30 (8 years ago) parenta43b671
3 files changed+28−1
Changelog.md+1−1 src/Streamly/Prelude.hs+24 src/Streamly/Streams/Serial.hs+3
Changelog.md+1−1
@@ -36,7 +36,7 @@
3636
3737* Add concurrency control primitives `maxThreads` and `maxBuffer`.
3838* Concurrency of a stream with bounded concurrency when used with `take` is now
39− limited by the number elements demanded by `take`.
39+ limited by the number of elements demanded by `take`.
4040* Significant performance improvements utilizing stream fusion optimizations.
4141* Add `yield` to construct a singleton stream from a pure value
4242* Add `repeat` to generate an infinite stream by repeating a pure value
src/Streamly/Prelude.hs+24
@@ -495,6 +495,8 @@ foldr f = foldrM (\a b -> return (f a b))
495495
496496-- | Right fold, for non-empty streams, using first element as the starting
497497-- value. Returns 'Nothing' if the stream is empty.
498+--
499+-- @since 0.5.0
498500{-# INLINE foldr1 #-}
499501foldr1 :: Monad m => (a -> a -> a) -> SerialT m a -> m (Maybe a)
500502foldr1 = K.foldr1
@@ -524,6 +526,8 @@ foldl' step begin m = S.foldl' step begin $ toStreamS m
524526
525527-- | Strict left fold, for non-empty streams, using first element as the
526528-- starting value. Returns 'Nothing' if the stream is empty.
529+--
530+-- @since 0.5.0
527531foldl1' :: Monad m => (a -> a -> a) -> SerialT m a -> m (Maybe a)
528532foldl1' step m = do
529533 r <- uncons m
@@ -578,6 +582,8 @@ tail :: (IsStream t, Monad m) => SerialT m a -> m (Maybe (t m a))
578582tail m = K.tail (K.adapt m)
579583
580584-- | Extract all but the last element of the stream, if any.
585+--
586+-- @since 0.5.0
581587{-# INLINE init #-}
582588init :: (IsStream t, Monad m) => SerialT m a -> m (Maybe (t m a))
583589init m = K.init (K.adapt m)
@@ -625,11 +631,15 @@ any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
625631any p m = S.any p (toStreamS m)
626632
627633-- | Determines if all elements of a boolean stream are True.
634+--
635+-- @since 0.5.0
628636{-# INLINE and #-}
629637and :: Monad m => SerialT m Bool -> m Bool
630638and = all (==True)
631639
632640-- | Determines wheter at least one element of a boolean stream is True.
641+--
642+-- @since 0.5.0
633643{-# INLINE or #-}
634644or :: Monad m => SerialT m Bool -> m Bool
635645or = any (==True)
@@ -663,34 +673,46 @@ maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
663673maximum m = S.maximum (toStreamS m)
664674
665675-- | Looks the given key up, treating the given stream as an association list.
676+--
677+-- @since 0.5.0
666678{-# INLINE lookup #-}
667679lookup :: (Monad m, Eq a) => a -> SerialT m (a, b) -> m (Maybe b)
668680lookup = K.lookup
669681
670682-- | Returns the first element of the stream satisfying the given predicate,
671683-- if any.
684+--
685+-- @since 0.5.0
672686{-# INLINE find #-}
673687find :: Monad m => (a -> Bool) -> SerialT m a -> m (Maybe a)
674688find = K.find
675689
676690-- | Finds all the indices of elements satisfying the given predicate.
691+--
692+-- @since 0.5.0
677693{-# INLINE findIndices #-}
678694findIndices :: IsStream t => (a -> Bool) -> t m a -> t m Int
679695findIndices = K.findIndices
680696
681697-- | Gives the index of the first stream element satisfying the given
682698-- preficate.
699+--
700+-- @since 0.5.0
683701{-# INLINE findIndex #-}
684702findIndex :: Monad m => (a -> Bool) -> SerialT m a -> m (Maybe Int)
685703findIndex p = head . findIndices p
686704
687705-- | Finds the index of all elements in the stream which are equal to the
688706-- given.
707+--
708+-- @since 0.5.0
689709{-# INLINE elemIndices #-}
690710elemIndices :: (IsStream t, Eq a) => a -> t m a -> t m Int
691711elemIndices a = findIndices (==a)
692712
693713-- | Gives the first index of an element in the stream, which equals the given.
714+--
715+-- @since 0.5.0
694716{-# INLINE elemIndex #-}
695717elemIndex :: (Monad m, Eq a) => a -> SerialT m a -> m (Maybe Int)
696718elemIndex a = findIndex (==a)
@@ -927,6 +949,8 @@ reverse m = fromStream $ go K.nil (toStream m)
927949
928950-- | Generate a stream by performing the monadic action inbetween all elements
929951-- of the given stream.
952+--
953+-- @since 0.5.0
930954{-# INLINE intersperseM #-}
931955intersperseM :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
932956intersperseM = K.intersperseM
src/Streamly/Streams/Serial.hs+3
@@ -188,6 +188,9 @@ instance Monad m => Monad (SerialT m) where
188188mapM :: (IsStream t, Monad m) => (a -> m b) -> t m a -> t m b
189189mapM f m = fromStream $ D.toStreamK $ D.mapM f $ D.fromStreamK (toStream m)
190190
191+-- | Same as 'fmap'.
192+--
193+-- @since 0.4.0
191194{-# INLINE map #-}
192195map :: (IsStream t, Monad m) => (a -> b) -> t m a -> t m b
193196map f = mapM (return . f)