polysemy-0.6.0.0: Higher-order, low-boilerplate, zero-cost free monads.

Safe HaskellNone
LanguageHaskell2010

Polysemy.Async

Contents

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)) 
Await :: Async a -> Async m a 
Instances
type DefiningModule Async Source # 
Instance details

Defined in Polysemy.Async

type DefiningModule Async = "Polysemy.Async"

Actions

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

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

Interpretations

runAsync :: LastMember (Lift IO) r => Sem (Async ': r) a -> Sem r a Source #

A more flexible --- though less performant --- version of runAsyncInIO.

This function is capable of running Async effects anywhere within an effect stack, without relying on an explicit function to lower it into IO. Notably, this means that State effects will be consistent in the presence of Async.

Since: 0.5.0.0

runAsyncInIO Source #

Arguments

:: Member (Lift IO) r 
=> (forall x. Sem r x -> IO x)

Strategy for lowering a Sem action down to IO. This is likely some combination of runM and other interpreters composed via .@.

-> Sem (Async ': r) a 
-> Sem r a 

Run an Async effect via in terms of async.

Since: 0.5.0.0