bluefin-0.6.0.0: The Bluefin effect system
Safe HaskellNone
LanguageHaskell2010

Bluefin.Capability.Await

Synopsis

Documentation

Await allows you to await values during the execution of a Bluefin operation. It provides similar functionality to await from Conduit or Pipes.

For information about prompt finalization/resource safety when using Bluefin Consumes, see Bluefin.Coroutine.

Capability

type Await a = Consume a #

Capability to await values of type a

Handlers

eachAwait #

Arguments

:: forall b (es :: Effects) r. (forall (e :: Effects). Await b e -> Eff (e :& es) r)

Body

-> Eff es b

Value to send to each await in the body.

-> Eff es r 

A version of forEach specialized to Await. Every time the Await is used to await a b, feed it the one created by the handler.

awaitYield #

Arguments

:: forall a (es :: Effects) r. (forall (e :: Effects). Await a e -> Eff (e :& es) r)

Starts running first. Each await from the Consume ...

-> (forall (e :: Effects). Yield a e -> Eff (e :& es) r)

... receives the value yielded from the Yield

-> Eff es r 

awaitYield is connectRequests specialized to Await and Yield, which is the most common case.

Effectful operations

await :: forall (e :: Effects) (es :: Effects) a. e <: es => Consume a e -> Eff es a #

takeAwait #

Arguments

:: forall (e1 :: Effects) (es :: Effects) (e2 :: Effects) a. (e1 <: es, e2 <: es) 
=> Int 
-> Await a e1 
-> Yield a e2 
-> Eff es ()

͘

runPureEff $ yieldToList $ yOut -> do
  awaitYield
    (\c -> takeAwait 4 c yOut)
    (\yIn -> inFoldable [1..10] yIn)
([1,2,3,4],())