HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulestreamly-0.10.1Haskell2010

Streamly.Internal.Data.Stream.Async

Deprecated. Please use Streamly.Internal.Data.Stream.Concurrent from streamly package instead.

To run examples in this module:

Example3 expressions
import qualified Streamly.Prelude as Streamimport Control.Concurrent (threadDelay):{ delay n = do     threadDelay (n * 1000000)   -- sleep for n seconds     putStrLn (show n ++ " sec") -- print "n sec"     return n                    -- IO Int:}
  • 4 types
  • 6 values
  • Packagestreamly-0.10.1
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceAsync.hs
newtypenewtype AsyncT (m :: Type -> Type) a
#

For AsyncT streams:

(<>) = Streamly.Prelude.async
(>>=) = flip . Streamly.Prelude.concatMapWith Streamly.Prelude.async

A single Monad bind behaves like a for loop with iterations of the loop executed concurrently a la the async combinator, producing results and side effects of iterations out of order:

Example1 expression
:{Stream.toList $ Stream.fromAsync $ do     x <- Stream.fromList [2,1] -- foreach x in stream     Stream.fromEffect $ delay x:}1 sec2 sec[1,2]

Nested monad binds behave like nested for loops with nested iterations executed concurrently, a la the async combinator:

Example1 expression
:{Stream.toList $ Stream.fromAsync $ do    x <- Stream.fromList [1,2] -- foreach x in stream    y <- Stream.fromList [2,4] -- foreach y in stream    Stream.fromEffect $ delay (x + y):}3 sec4 sec5 sec6 sec[3,4,5,6]

The behavior can be explained as follows. All the iterations corresponding to the element 1 in the first stream constitute one output stream and all the iterations corresponding to 2 constitute another output stream and these two output streams are merged using async.

Since: 0.1.0 (Streamly)

Constructors

Instances10IsStream, MonadReader, MonadState, Monad, Functor, Applicative, …
typetype Async = AsyncT IO
#

A demand driven left biased parallely composing IO stream of elements of type a. See AsyncT documentation for more details.

Since: 0.2.0 (Streamly)

valueconsMAsync :: MonadAsync m => m a -> AsyncT m a -> AsyncT m a
#

XXX we can implement it more efficienty by directly implementing instead of combining streams using async.

valuemkAsyncK :: MonadAsync m => Stream m a -> Stream m a
#

Generate a stream asynchronously to keep it buffered, lazily consume from the buffer.

Pre-release

newtypenewtype WAsyncT (m :: Type -> Type) a
#

For WAsyncT streams:

(<>) = Streamly.Prelude.wAsync
(>>=) = flip . Streamly.Prelude.concatMapWith Streamly.Prelude.wAsync

A single Monad bind behaves like a for loop with iterations of the loop executed concurrently a la the wAsync combinator, producing results and side effects of iterations out of order:

Example1 expression
:{Stream.toList $ Stream.fromWAsync $ do     x <- Stream.fromList [2,1] -- foreach x in stream     Stream.fromEffect $ delay x:}1 sec2 sec[1,2]

Nested monad binds behave like nested for loops with nested iterations executed concurrently, a la the wAsync combinator:

Example1 expression
:{Stream.toList $ Stream.fromWAsync $ do    x <- Stream.fromList [1,2] -- foreach x in stream    y <- Stream.fromList [2,4] -- foreach y in stream    Stream.fromEffect $ delay (x + y):}3 sec4 sec5 sec6 sec[3,4,5,6]

The behavior can be explained as follows. All the iterations corresponding to the element 1 in the first stream constitute one WAsyncT output stream and all the iterations corresponding to 2 constitute another WAsyncT output stream and these two output streams are merged using wAsync.

The W in the name stands for wide or breadth wise scheduling in contrast to the depth wise scheduling behavior of AsyncT.

Since: 0.2.0 (Streamly)

Constructors

Instances10IsStream, MonadReader, MonadState, Monad, Functor, Applicative, …
typetype WAsync = WAsyncT IO
#

A round robin parallely composing IO stream of elements of type a. See WAsyncT documentation for more details.

Since: 0.2.0 (Streamly)

valueconsMWAsync :: MonadAsync m => m a -> WAsyncT m a -> WAsyncT m a
#

XXX we can implement it more efficienty by directly implementing instead of combining streams using wAsync.