polysemy-1.9.0.0: Higher-order, low-boilerplate free monads.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Async

Description

 
Synopsis

Effect

data Async m a where Source #

An effect for spawning asynchronous computations.

The Maybe returned by async is due to the fact that we can't be sure an Error effect didn't fail locally.

Since: 0.5.0.0

Constructors

Async :: m a -> Async m (Async (Maybe a))

Run the given action asynchronously and return a thread handle.

Await :: Async a -> Async m a

Wait for the thread referenced by the given handle to terminate.

Cancel :: Async a -> Async m ()

Cancel the thread referenced by the given handle.

Actions

async :: forall r a. Member Async r => Sem r a -> Sem r (Async (Maybe a)) Source #

Run the given action asynchronously and return a thread handle.

await :: forall r a. Member Async r => Async a -> Sem r a Source #

Wait for the thread referenced by the given handle to terminate.

cancel :: forall r a. Member Async r => Async a -> Sem r () Source #

Cancel the thread referenced by the given handle.

Helpers

sequenceConcurrently :: forall t r a. (Traversable t, Member Async r) => t (Sem r a) -> Sem r (t (Maybe a)) Source #

Perform a sequence of effectful actions concurrently.

Since: 1.2.2.0

Interpretations

asyncToIOFinal :: Member (Final IO) r => Sem (Async ': r) a -> Sem r a Source #

Run an Async effect in terms of async through final IO.

Beware: Effects that aren't interpreted in terms of IO will have local state semantics in regards to Async effects interpreted this way. See Final.

Since: 1.2.0.0