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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Api.Client

Contents

Description

Functions for Api clients.

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

Synopsis

Calling APIs directly

cast :: forall r q o. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable o, Typeable (Api o Asynchronous)) => 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. The operation never fails, if it is important to know if the message was delivered, use call instead.

call :: forall result api r q. (SetMember Process (Process q) r, Member Interrupts r, Typeable api, Typeable (Api api (Synchronous result)), Typeable result, HasCallStack, NFData result, Show result) => 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.

Server Process Registration

castRegistered :: (Typeable o, ServesApi o r q, HasCallStack, Member Interrupts r) => 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, HasCallStack, NFData reply, Show reply, Member Interrupts r) => Api o (Synchronous reply) -> Eff r reply Source #

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

type ServesApi o r q = (Typeable o, SetMember Process (Process q) r, Member (ServerReader 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.

type ServerReader o = Reader (Server o) Source #

The reader effect for ProcessIds for Apis, see registerServer

whereIsServer :: Member (ServerReader o) e => Eff e (Server o) Source #

Get the Server registered with registerServer.

registerServer :: HasCallStack => Server o -> Eff (ServerReader o ': r) a -> Eff r a Source #

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