@@ -43,8 +43,8 @@ module Streamly.Streams
49 -- * Merging Streams
49 -- * Merging Streams
@@ -54,6 +54,7 @@ module Streamly.Streams
55 , parallel
55 , parallel
56 , (<=>) --deprecated
56 , (<=>) --deprecated
58 -- * IO Streams
59 -- * IO Streams
@@ -330,6 +331,12 @@ runWith :: (IsStream t, MonadAsync m)
330 => SVarStyle -> (t m a -> m b) -> t m a -> m b
331 => SVarStyle -> (t m a -> m b) -> t m a -> m b
331runWith style f x = S.runWith style (f . fromStream) (toStream x)
332runWith style f x = S.runWith style (f . fromStream) (toStream x)
333-- | Parallel function application operator for streams; just like the regular
340-- | Parallel function application operator for streams; just like the regular
334-- function application operator '$' except that it is concurrent. The
341-- function application operator '$' except that it is concurrent. The
335-- following code prints a value every second even though each stage adds a 1
342-- following code prints a value every second even though each stage adds a 1
@@ -369,34 +376,35 @@ x |& f = f |$ x
369-- | Parallel function application operator; applies a @run@ or @fold@ function
376-- | Parallel function application operator; applies a @run@ or @fold@ function
370-- to a stream such that the fold consumer and the stream producer run in
377-- to a stream such that the fold consumer and the stream producer run in
371-- parallel. A @run@ or @fold@ function reduces the stream to a value in the
378-- parallel. A @run@ or @fold@ function reduces the stream to a value in the
372−-- underlying monad.
379+-- underlying monad. The @.@ at the end of the operator is a mnemonic for
380+-- termination of the stream.
375-- S.foldlM' (\\_ a -> threadDelay 1000000 >> print a) ()
383-- S.foldlM' (\\_ a -> threadDelay 1000000 >> print a) ()
376−-- <| S.repeatM (threadDelay 1000000 >> return 1)
384+-- |$. S.repeatM (threadDelay 1000000 >> return 1)
379-- /Concurrent/
387-- /Concurrent/
381-- @since 0.3.0
389-- @since 0.3.0
382−{-# INLINE (<|) #-}
390+{-# INLINE (|$.) #-}
383−(<|) :: (IsStream t, MonadAsync m) => (t m a -> m b) -> t m a -> m b
391+(|$.) :: (IsStream t, MonadAsync m) => (t m a -> m b) -> t m a -> m b
384−f <| x = runWith ParallelVar f x
392+f |$. x = runWith ParallelVar f x
386-- | Parallel reverse function application operator for applying a run or fold
394-- | Parallel reverse function application operator for applying a run or fold
387−-- functions to a stream. Just like '<|' except that the operands are reversed.
395+-- functions to a stream. Just like '|$.' except that the operands are reversed.
390−-- S.repeatM (threadDelay 1000000 >> return 1)
398+-- S.repeatM (threadDelay 1000000 >> return 1)
391−-- |> S.foldlM' (\\_ a -> threadDelay 1000000 >> print a) ()
399+-- |&. S.foldlM' (\\_ a -> threadDelay 1000000 >> print a) ()
394-- /Concurrent/
402-- /Concurrent/
396-- @since 0.3.0
404-- @since 0.3.0
397−{-# INLINE (|>) #-}
405+{-# INLINE (|&.) #-}
398−(|>) :: (IsStream t, MonadAsync m) => t m a -> (t m a -> m b) -> m b
406+(|&.) :: (IsStream t, MonadAsync m) => t m a -> (t m a -> m b) -> m b
399−x |> f = f <| x
407+x |&. f = f |$. x
401------------------------------------------------------------------------------
409------------------------------------------------------------------------------
402-- CPP macros for common instances
410-- CPP macros for common instances
@@ -884,6 +892,14 @@ instance IsStream AsyncT where
884async :: (IsStream t, MonadAsync m) => t m a -> t m a -> t m a
892async :: (IsStream t, MonadAsync m) => t m a -> t m a -> t m a
885async m1 m2 = fromStream $ S.async (toStream m1) (toStream m2)
893async m1 m2 = fromStream $ S.async (toStream m1) (toStream m2)
895+-- | Same as 'async'.
898+{-# DEPRECATED (<|) "Please use 'async' instead." #-}
900+(<|) :: (IsStream t, MonadAsync m) => t m a -> t m a -> t m a
887instance MonadAsync m => Semigroup (AsyncT m a) where
903instance MonadAsync m => Semigroup (AsyncT m a) where
888 (<>) = async
904 (<>) = async