on master help sign in
hide some combinators, fix doc, since notations
9d48b5bHarendra Kumar
src/Streamly/Prelude.hs+47−20
@@ -370,13 +370,13 @@ module Streamly.Prelude
370 , insertBy
370 , insertBy
371 , intersperseM
371 , intersperseM
372 , intersperse
372 , intersperse
373− , insertAfterEach
373+ -- , insertAfterEach
374 -- , intersperseBySpan
374 -- , intersperseBySpan
375− , intersperseByTime
375+ -- , intersperseByTime
376
376
377 -- ** Reordering
377 -- ** Reordering
378 , reverse
378 , reverse
379− , reverse'
379+ -- , reverse'
380
380
381 -- * Multi-Stream Operations
381 -- * Multi-Stream Operations
382 -- | New streams can be constructed by appending, merging or zipping
382 -- | New streams can be constructed by appending, merging or zipping
@@ -815,7 +815,9 @@ iterate step = fromStream . go
815--
815--
816-- /Concurrent/
816-- /Concurrent/
817--
817--
818−-- @since 0.1.2
818+-- /Since: 0.7.0 (signature change)/
819+--
820+-- /Since: 0.1.2/
819iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> m a -> t m a
821iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> m a -> t m a
820iterateM step = go
822iterateM step = go
821 where
823 where
@@ -872,7 +874,7 @@ each = K.fromFoldable
872-- | Read lines from an IO Handle into a stream of Strings.
874-- | Read lines from an IO Handle into a stream of Strings.
873--
875--
874-- @since 0.1.0
876-- @since 0.1.0
875−{-# DEPRECATED fromHandle "Please use Streamly.FileIO instead." #-}
877+{-# DEPRECATED fromHandle "Please use Streamly.FileSystem.Handle instead." #-}
876fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
878fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
877fromHandle h = go
879fromHandle h = go
878 where
880 where
@@ -983,7 +985,11 @@ fromHandle h = go
983-- incrementally in FIFO style. Therefore, a strict left fold is more suitable
985-- incrementally in FIFO style. Therefore, a strict left fold is more suitable
984-- for reductions.
986-- for reductions.
985--
987--
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/
987{-# INLINE foldrM #-}
993{-# INLINE foldrM #-}
988foldrM :: Monad m => (a -> m b -> m b) -> m b -> SerialT m a -> m b
994foldrM :: Monad m => (a -> m b -> m b) -> m b -> SerialT m a -> m b
989foldrM = P.foldrM
995foldrM = P.foldrM
@@ -1209,11 +1215,16 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
1209-- as 'SerialT', to run other types of streams use the type adapting
1215-- as 'SerialT', to run other types of streams use the type adapting
1210-- combinators for example @drain . 'asyncly'@.
1216-- combinators for example @drain . 'asyncly'@.
1211--
1217--
1212−-- @since 0.2.0
1218+-- @since 0.7.0
1213{-# INLINE drain #-}
1219{-# INLINE drain #-}
1214drain :: Monad m => SerialT m a -> m ()
1220drain :: Monad m => SerialT m a -> m ()
1215drain = P.drain
1221drain = P.drain
1216
1222
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
1217{-# DEPRECATED runStream "Please use \"drain\" instead" #-}
1228{-# DEPRECATED runStream "Please use \"drain\" instead" #-}
1218{-# INLINE runStream #-}
1229{-# INLINE runStream #-}
1219runStream :: Monad m => SerialT m a -> m ()
1230runStream :: Monad m => SerialT m a -> m ()
@@ -1229,6 +1240,12 @@ runStream = drain
1229drainN :: Monad m => Int -> SerialT m a -> m ()
1240drainN :: Monad m => Int -> SerialT m a -> m ()
1230drainN n = drain . take n
1241drainN n = drain . take n
1231
1242
1243+-- |
1244+-- > runN n = runStream . take n
1245+--
1246+-- Run maximum up to @n@ iterations of a stream.
1247+--
1248+-- @since 0.6.0
1232{-# DEPRECATED runN "Please use \"drainN\" instead" #-}
1249{-# DEPRECATED runN "Please use \"drainN\" instead" #-}
1233{-# INLINE runN #-}
1250{-# INLINE runN #-}
1234runN :: Monad m => Int -> SerialT m a -> m ()
1251runN :: Monad m => Int -> SerialT m a -> m ()
@@ -1239,11 +1256,17 @@ runN = drainN
1239--
1256--
1240-- Run a stream as long as the predicate holds true.
1257-- Run a stream as long as the predicate holds true.
1241--
1258--
1242−-- @since 0.6.0
1259+-- @since 0.7.0
1243{-# INLINE drainWhile #-}
1260{-# INLINE drainWhile #-}
1244drainWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
1261drainWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
1245drainWhile p = drain . takeWhile p
1262drainWhile p = drain . takeWhile p
1246
1263
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
1247{-# DEPRECATED runWhile "Please use \"drainWhile\" instead" #-}
1270{-# DEPRECATED runWhile "Please use \"drainWhile\" instead" #-}
1248{-# INLINE runWhile #-}
1271{-# INLINE runWhile #-}
1249runWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
1272runWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
@@ -1566,7 +1589,7 @@ _toListRev = D.toListRev . toStreamD
1566-- Write a stream of Strings to an IO Handle.
1589-- Write a stream of Strings to an IO Handle.
1567--
1590--
1568-- @since 0.1.0
1591-- @since 0.1.0
1569−{-# DEPRECATED toHandle "Please use Streamly.FileIO instead." #-}
1592+{-# DEPRECATED toHandle "Please use Streamly.FileSystem.Handle instead." #-}
1570toHandle :: MonadIO m => IO.Handle -> SerialT m String -> m ()
1593toHandle :: MonadIO m => IO.Handle -> SerialT m String -> m ()
1571toHandle h m = go m
1594toHandle h m = go m
1572 where
1595 where
@@ -1604,7 +1627,9 @@ _transform pipe xs = fromStreamD $ D.transform pipe (toStreamD xs)
1604-- designed to work with the @foldl@ library. The suffix @x@ is a mnemonic for
1627-- designed to work with the @foldl@ library. The suffix @x@ is a mnemonic for
1605-- extraction.
1628-- extraction.
1606--
1629--
1607−-- @since 0.2.0
1630+-- /Since: 0.7.0 (Monad m constraint)/
1631+--
1632+-- /Since 0.2.0/
1608{-# DEPRECATED scanx "Please use scanl followed by map instead." #-}
1633{-# DEPRECATED scanx "Please use scanl followed by map instead." #-}
1609{-# INLINE scanx #-}
1634{-# INLINE scanx #-}
1610scanx :: (IsStream t, Monad m) => (x -> a -> x) -> x -> (x -> b) -> t m a -> t m b
1635scanx :: (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
1911-- /Note:/ 'reverse'' is much faster than this, use that when performance
1936-- /Note:/ 'reverse'' is much faster than this, use that when performance
1912-- matters.
1937-- matters.
1913--
1938--
1914−-- @since 0.1.1
1939+-- /Since 0.7.0 (Monad m constraint)/
1940+--
1941+-- /Since: 0.1.1/
1915{-# INLINE reverse #-}
1942{-# INLINE reverse #-}
1916reverse :: (IsStream t, Monad m) => t m a -> t m a
1943reverse :: (IsStream t, Monad m) => t m a -> t m a
1917reverse s = fromStreamS $ S.reverse $ toStreamS s
1944reverse s = fromStreamS $ S.reverse $ toStreamS s
@@ -1919,9 +1946,9 @@ reverse s = fromStreamS $ S.reverse $ toStreamS s
1919-- | Like 'reverse' but several times faster, requires a 'Storable' instance.
1946-- | Like 'reverse' but several times faster, requires a 'Storable' instance.
1920--
1947--
1921-- @since 0.7.0
1948-- @since 0.7.0
1922−{-# INLINE reverse' #-}
1949+{-# INLINE _reverse' #-}
1923−reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
1950+_reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
1924−reverse' s = fromStreamD $ D.reverse' $ toStreamD s
1951+_reverse' s = fromStreamD $ D.reverse' $ toStreamD s
1925
1952
1926------------------------------------------------------------------------------
1953------------------------------------------------------------------------------
1927-- Transformation by Inserting
1954-- Transformation by Inserting
@@ -1960,9 +1987,9 @@ intersperse a = fromStreamS . S.intersperse a . toStreamS
1960-- | Insert a monadic action after each element in the stream.
1987-- | Insert a monadic action after each element in the stream.
1961--
1988--
1962-- @since 0.7.0
1989-- @since 0.7.0
1963−{-# INLINE insertAfterEach #-}
1990+{-# INLINE _insertAfterEach #-}
1964−insertAfterEach :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
1991+_insertAfterEach :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
1965−insertAfterEach m = fromStreamD . D.insertAfterEach m . toStreamD
1992+_insertAfterEach m = fromStreamD . D.insertAfterEach m . toStreamD
1966
1993
1967{-
1994{-
1968-- | Intersperse a monadic action into the input stream after every @n@
1995-- | Intersperse a monadic action into the input stream after every @n@
@@ -1988,11 +2015,11 @@ intersperseBySpan _n _f _xs = undefined
1988-- @
2015-- @
1989--
2016--
1990-- @since 0.7.0
2017-- @since 0.7.0
1991−{-# INLINE intersperseByTime #-}
2018+{-# INLINE _intersperseByTime #-}
1992−intersperseByTime
2019+_intersperseByTime
1993 :: (IsStream t, MonadAsync m)
2020 :: (IsStream t, MonadAsync m)
1994 => Double -> m a -> t m a -> t m a
2021 => 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
1996 where timed = liftIO (threadDelay (round $ n * 1000000)) >> f
2023 where timed = liftIO (threadDelay (round $ n * 1000000)) >> f
1997
2024
1998-- | @insertBy cmp elem stream@ inserts @elem@ before the first element in
2025-- | @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
268--
268--
269-- @foldWith 'async' $ map return [1..3]@
269-- @foldWith 'async' $ map return [1..3]@
270--
270--
271−-- @since 0.1.0
271+-- /Since: 0.7.0 ("Streamly.Prelude")/
272+--
273+-- /Since: 0.1.0 ("Streamly")/
272{-# INLINABLE foldWith #-}
274{-# INLINABLE foldWith #-}
273foldWith :: (IsStream t, Foldable f)
275foldWith :: (IsStream t, Foldable f)
274 => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
276 => (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
280--
282--
281-- @foldMapWith 'async' return [1..3]@
283-- @foldMapWith 'async' return [1..3]@
282--
284--
283−-- @since 0.1.0
285+-- /Since: 0.7.0 ("Streamly.Prelude")/
286+--
287+-- /Since: 0.1.0 ("Streamly")/
284{-# INLINABLE foldMapWith #-}
288{-# INLINABLE foldMapWith #-}
285foldMapWith :: (IsStream t, Foldable f)
289foldMapWith :: (IsStream t, Foldable f)
286 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
290 => (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
289-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
293-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
290-- monadic streaming function is the last argument.
294-- monadic streaming function is the last argument.
291--
295--
292−-- @since 0.1.0
296+-- /Since: 0.7.0 ("Streamly.Prelude")/
297+--
298+-- /Since: 0.1.0 ("Streamly")/
293{-# INLINABLE forEachWith #-}
299{-# INLINABLE forEachWith #-}
294forEachWith :: (IsStream t, Foldable f)
300forEachWith :: (IsStream t, Foldable f)
295 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b
301 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b