extensible-effects-concurrent-0.3.0.1: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Api.Client

Description

Functions for Api clients.

This modules is required to write clients that consume an Api.

Synopsis

Documentation

cast :: forall r q o. (HasCallStack, SetMember Process (Process q) r, Typeable o, Typeable (Api o Asynchronous)) => SchedulerProxy q -> Server o -> Api o Asynchronous -> Eff r () Source #

Send an Api request that has no return value and return as fast as possible. The type signature enforces that the corresponding Api clause is Asynchronous.

castChecked :: forall r q o. (HasCallStack, SetMember Process (Process q) r, Typeable o, Typeable (Api o Asynchronous)) => SchedulerProxy q -> Server o -> Api o Asynchronous -> Eff r Bool Source #

Send an Api request that has no return value and return as fast as possible. The type signature enforces that the corresponding Api clause is Asynchronous. Return True if the message was sent to the process. Note that this is totally not the same as that the request was successfully handled. If that is important, use call instead.

call :: forall result api r q. (SetMember Process (Process q) r, Typeable api, Typeable (Api api (Synchronous result)), Typeable result, HasCallStack) => SchedulerProxy q -> Server api -> Api api (Synchronous result) -> Eff r result Source #

Send an Api request and wait for the server to return a result value.

The type signature enforces that the corresponding Api clause is Synchronous.

castRegistered :: (Typeable o, ServesApi o r q) => SchedulerProxy q -> Api o Asynchronous -> Eff r () Source #

Like cast but take the Server from the reader provided by registerServer.

callRegistered :: (Typeable reply, ServesApi o r q) => SchedulerProxy q -> Api o (Synchronous reply) -> Eff r reply Source #

Like call but take the Server from the reader provided by registerServer.

callRegisteredA :: forall r q o f reply. (Alternative f, Typeable f, Typeable reply, ServesApi o r q) => SchedulerProxy q -> Api o (Synchronous (f reply)) -> Eff r (f reply) Source #

Like callRegistered but also catch errors raised if e.g. the server crashed. By allowing Alternative instances to contain the reply, application level errors can be combined with errors rising from inter process communication.

type ServesApi o r q = (Typeable o, SetMember Process (Process q) r, Member (Reader (Server o)) r) Source #

Instead of passing around a Server value and passing to functions like cast or call, a Server can provided by a Reader effect, if there is only a single server for a given Api instance. This type alias is convenience to express that an effect has Process and a reader for a Server.

registerServer :: Server o -> Eff (Reader (Server o) ': r) a -> Eff r a Source #

Run a reader effect that contains the one server handling a specific Api instance.