scoped-codensity-0.1.0.0: CPS resource allocation but as a Monad and completely safe
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Scoped.Async

Description

Functions and types for safely working with Asyncs in Scoped blocks

Synopsis

Scoped Async

type ScopedAsync s a = ScopedResource s (Async a) Source #

Just like Async but bound to a Scoped block

Allocating a new ScopedAsync in a Scoped block

async :: MonadUnliftIO m => m a -> Scoped s m (ScopedAsync s a) Source #

Run an IO action asynchronously in a Scoped block. When the Scoped block ends, the Async is cancelled

asyncBound :: MonadUnliftIO m => m a -> Scoped s m (ScopedAsync s a) Source #

Like async but uses forkOS internally

Waiting for a ScopedAsync to finish

wait :: MonadIO m => ScopedAsync s a -> Scoped s m a Source #

Wait for the ScopedAsync to finish immediately

waitCatch :: MonadIO m => ScopedAsync s a -> Scoped s m (Either SomeException a) Source #

Like wait but return either Left SomeException or Right a

Waiting for a ScopedAsync to finish as part of the handlers of the Scoped block

waitScoped :: MonadUnliftIO m => ScopedAsync s a -> Scoped s m () Source #

Like wait but wait as part of the handlers of the Scoped block

waitCatchScoped :: MonadUnliftIO m => ScopedAsync s a -> Scoped s m () Source #

Like waitCatch but wait as part of the handlers of the Scoped block