on master help sign in
hide some combinators, fix doc, since notations
commit9d48b5b422870e057fb7e317e5f5040ae3288f53 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 2 Aug 2019, 03:06 (7 years ago) parentfdec798
2 files changed+56−23
src/Streamly/Prelude.hs+47−20 src/Streamly/Streams/Prelude.hs+9−3
src/Streamly/Prelude.hs+47−20
@@ -370,13 +370,13 @@ module Streamly.Prelude
370370 , insertBy
371371 , intersperseM
372372 , intersperse
373− , insertAfterEach
373+ -- , insertAfterEach
374374 -- , intersperseBySpan
375− , intersperseByTime
375+ -- , intersperseByTime
376376
377377 -- ** Reordering
378378 , reverse
379− , reverse'
379+ -- , reverse'
380380
381381 -- * Multi-Stream Operations
382382 -- | New streams can be constructed by appending, merging or zipping
@@ -815,7 +815,9 @@ iterate step = fromStream . go
815815--
816816-- /Concurrent/
817817--
818−-- @since 0.1.2
818+-- /Since: 0.7.0 (signature change)/
819+--
820+-- /Since: 0.1.2/
819821iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> m a -> t m a
820822iterateM step = go
821823 where
@@ -872,7 +874,7 @@ each = K.fromFoldable
872874-- | Read lines from an IO Handle into a stream of Strings.
873875--
874876-- @since 0.1.0
875−{-# DEPRECATED fromHandle "Please use Streamly.FileIO instead." #-}
877+{-# DEPRECATED fromHandle "Please use Streamly.FileSystem.Handle instead." #-}
876878fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
877879fromHandle h = go
878880 where
@@ -983,7 +985,11 @@ fromHandle h = go
983985-- incrementally in FIFO style. Therefore, a strict left fold is more suitable
984986-- for reductions.
985987--
986−-- @since 0.7.0
988+-- /Since: 0.7.0 (signature changed)/
989+--
990+-- /Since: 0.2.0 (signature changed)/
991+--
992+-- /Since: 0.1.0/
987993{-# INLINE foldrM #-}
988994foldrM :: Monad m => (a -> m b -> m b) -> m b -> SerialT m a -> m b
989995foldrM = P.foldrM
@@ -1209,11 +1215,16 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
12091215-- as 'SerialT', to run other types of streams use the type adapting
12101216-- combinators for example @drain . 'asyncly'@.
12111217--
1212−-- @since 0.2.0
1218+-- @since 0.7.0
12131219{-# INLINE drain #-}
12141220drain :: Monad m => SerialT m a -> m ()
12151221drain = P.drain
12161222
1223+-- | Run a stream, discarding the results. By default it interprets the stream
1224+-- as 'SerialT', to run other types of streams use the type adapting
1225+-- combinators for example @runStream . 'asyncly'@.
1226+--
1227+-- @since 0.2.0
12171228{-# DEPRECATED runStream "Please use \"drain\" instead" #-}
12181229{-# INLINE runStream #-}
12191230runStream :: Monad m => SerialT m a -> m ()
@@ -1229,6 +1240,12 @@ runStream = drain
12291240drainN :: Monad m => Int -> SerialT m a -> m ()
12301241drainN n = drain . take n
12311242
1243+-- |
1244+-- > runN n = runStream . take n
1245+--
1246+-- Run maximum up to @n@ iterations of a stream.
1247+--
1248+-- @since 0.6.0
12321249{-# DEPRECATED runN "Please use \"drainN\" instead" #-}
12331250{-# INLINE runN #-}
12341251runN :: Monad m => Int -> SerialT m a -> m ()
@@ -1239,11 +1256,17 @@ runN = drainN
12391256--
12401257-- Run a stream as long as the predicate holds true.
12411258--
1242−-- @since 0.6.0
1259+-- @since 0.7.0
12431260{-# INLINE drainWhile #-}
12441261drainWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
12451262drainWhile p = drain . takeWhile p
12461263
1264+-- |
1265+-- > runWhile p = runStream . takeWhile p
1266+--
1267+-- Run a stream as long as the predicate holds true.
1268+--
1269+-- @since 0.6.0
12471270{-# DEPRECATED runWhile "Please use \"drainWhile\" instead" #-}
12481271{-# INLINE runWhile #-}
12491272runWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
@@ -1566,7 +1589,7 @@ _toListRev = D.toListRev . toStreamD
15661589-- Write a stream of Strings to an IO Handle.
15671590--
15681591-- @since 0.1.0
1569−{-# DEPRECATED toHandle "Please use Streamly.FileIO instead." #-}
1592+{-# DEPRECATED toHandle "Please use Streamly.FileSystem.Handle instead." #-}
15701593toHandle :: MonadIO m => IO.Handle -> SerialT m String -> m ()
15711594toHandle h m = go m
15721595 where
@@ -1604,7 +1627,9 @@ _transform pipe xs = fromStreamD $ D.transform pipe (toStreamD xs)
16041627-- designed to work with the @foldl@ library. The suffix @x@ is a mnemonic for
16051628-- extraction.
16061629--
1607−-- @since 0.2.0
1630+-- /Since: 0.7.0 (Monad m constraint)/
1631+--
1632+-- /Since 0.2.0/
16081633{-# DEPRECATED scanx "Please use scanl followed by map instead." #-}
16091634{-# INLINE scanx #-}
16101635scanx :: (IsStream t, Monad m) => (x -> a -> x) -> x -> (x -> b) -> t m a -> t m b
@@ -1911,7 +1936,9 @@ mapMaybeMSerial f m = fromStreamD $ D.mapMaybeM f $ toStreamD m
19111936-- /Note:/ 'reverse'' is much faster than this, use that when performance
19121937-- matters.
19131938--
1914−-- @since 0.1.1
1939+-- /Since 0.7.0 (Monad m constraint)/
1940+--
1941+-- /Since: 0.1.1/
19151942{-# INLINE reverse #-}
19161943reverse :: (IsStream t, Monad m) => t m a -> t m a
19171944reverse s = fromStreamS $ S.reverse $ toStreamS s
@@ -1919,9 +1946,9 @@ reverse s = fromStreamS $ S.reverse $ toStreamS s
19191946-- | Like 'reverse' but several times faster, requires a 'Storable' instance.
19201947--
19211948-- @since 0.7.0
1922−{-# INLINE reverse' #-}
1923−reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
1924−reverse' s = fromStreamD $ D.reverse' $ toStreamD s
1949+{-# INLINE _reverse' #-}
1950+_reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
1951+_reverse' s = fromStreamD $ D.reverse' $ toStreamD s
19251952
19261953------------------------------------------------------------------------------
19271954-- Transformation by Inserting
@@ -1960,9 +1987,9 @@ intersperse a = fromStreamS . S.intersperse a . toStreamS
19601987-- | Insert a monadic action after each element in the stream.
19611988--
19621989-- @since 0.7.0
1963−{-# INLINE insertAfterEach #-}
1964−insertAfterEach :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
1965−insertAfterEach m = fromStreamD . D.insertAfterEach m . toStreamD
1990+{-# INLINE _insertAfterEach #-}
1991+_insertAfterEach :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
1992+_insertAfterEach m = fromStreamD . D.insertAfterEach m . toStreamD
19661993
19671994{-
19681995-- | Intersperse a monadic action into the input stream after every @n@
@@ -1988,11 +2015,11 @@ intersperseBySpan _n _f _xs = undefined
19882015-- @
19892016--
19902017-- @since 0.7.0
1991−{-# INLINE intersperseByTime #-}
1992−intersperseByTime
2018+{-# INLINE _intersperseByTime #-}
2019+_intersperseByTime
19932020 :: (IsStream t, MonadAsync m)
19942021 => Double -> m a -> t m a -> t m a
1995−intersperseByTime n f xs = xs `Par.parallelEndByFirst` repeatM timed
2022+_intersperseByTime n f xs = xs `Par.parallelEndByFirst` repeatM timed
19962023 where timed = liftIO (threadDelay (round $ n * 1000000)) >> f
19972024
19982025-- | @insertBy cmp elem stream@ inserts @elem@ before the first element in
src/Streamly/Streams/Prelude.hs+9−3
@@ -268,7 +268,9 @@ foldbWith f = K.foldb f K.nil
268268--
269269-- @foldWith 'async' $ map return [1..3]@
270270--
271−-- @since 0.1.0
271+-- /Since: 0.7.0 ("Streamly.Prelude")/
272+--
273+-- /Since: 0.1.0 ("Streamly")/
272274{-# INLINABLE foldWith #-}
273275foldWith :: (IsStream t, Foldable f)
274276 => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
@@ -280,7 +282,9 @@ foldWith f = Prelude.foldr f K.nil
280282--
281283-- @foldMapWith 'async' return [1..3]@
282284--
283−-- @since 0.1.0
285+-- /Since: 0.7.0 ("Streamly.Prelude")/
286+--
287+-- /Since: 0.1.0 ("Streamly")/
284288{-# INLINABLE foldMapWith #-}
285289foldMapWith :: (IsStream t, Foldable f)
286290 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
@@ -289,7 +293,9 @@ foldMapWith f g = Prelude.foldr (f . g) K.nil
289293-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
290294-- monadic streaming function is the last argument.
291295--
292−-- @since 0.1.0
296+-- /Since: 0.7.0 ("Streamly.Prelude")/
297+--
298+-- /Since: 0.1.0 ("Streamly")/
293299{-# INLINABLE forEachWith #-}
294300forEachWith :: (IsStream t, Foldable f)
295301 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b