scoped-codensity-0.1.0.0: CPS resource allocation but as a Monad and completely safe
Safe HaskellNone
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 :: forall m a s (ss :: [Type]). MonadUnliftIO m => m a -> Scoped (s ': ss) m (ScopedAsync s a) Source #

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

asyncBound :: forall m a s (ss :: [Type]). MonadUnliftIO m => m a -> Scoped (s ': ss) m (ScopedAsync s a) Source #

Like async but uses forkOS internally

Waiting for a ScopedAsync to finish

wait :: forall (m :: Type -> Type) s (ss :: [Type]) a. (MonadIO m, s :< ss) => ScopedAsync s a -> Scoped ss m a Source #

Wait for the ScopedAsync to finish immediately

waitCatch :: forall (m :: Type -> Type) s (ss :: [Type]) a. (MonadIO m, s :< ss) => ScopedAsync s a -> Scoped ss 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 :: forall (m :: Type -> Type) s (ss :: [Type]) a. (MonadUnliftIO m, s :< ss) => ScopedAsync s a -> Scoped ss m () Source #

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

waitCatchScoped :: forall (m :: Type -> Type) s (ss :: [Type]) a. (MonadUnliftIO m, s :< ss) => ScopedAsync s a -> Scoped ss m () Source #

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