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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Api.Observer

Contents

Description

Observer Effects

This module supports the implementation of observers and observables. One use case is event propagation. The tools in this module are tailored towards Api servers/clients.

Synopsis

Observation API

class (Typeable p, Observable o) => Observer p o where Source #

An Api index that support observation of the another Api that is Observable.

Methods

observationMessage :: Server o -> Observation o -> Api p Asynchronous Source #

Wrap the Observation and the ProcessId (i.e. the Server) that caused the observation into an Api value that the Observable understands.

class (Typeable o, Typeable (Observation o)) => Observable o where Source #

An Api index that supports registration and de-registration of Observers.

Associated Types

data Observation o Source #

Type of observations visible on this observable

Methods

registerObserverMessage :: SomeObserver o -> Api o Asynchronous Source #

Return the Api value for the cast_ that registeres an observer

forgetObserverMessage :: SomeObserver o -> Api o Asynchronous Source #

Return the Api value for the cast_ that de-registeres an observer

Generalized observation

data SomeObserver o where Source #

An existential wrapper around a Server of an Observer. Needed to support different types of observers to observe the same Observable in a general fashion.

Constructors

SomeObserver :: (Show (Server p), Typeable p, Observer p o) => Server p -> SomeObserver o 

data Observers o Source #

Internal state for manageObservers

type ObserverState o = State (Observers o) Source #

Alias for the effect that contains the observers managed by manageObservers

manageObservers :: Eff (ObserverState o ': r) a -> Eff r a Source #

Keep track of registered Observers Observers can be added and removed, and an Observation can be sent to all registerd observers at once.

notifyObservers :: forall o r q. (Observable o, SetMember Process (Process q) r, Member (ObserverState o) r, Member Interrupts r) => SchedulerProxy q -> Observation o -> Eff r () Source #

Send an Observation to all SomeObservers in the Observers state.

Callback Observer

data CallbackObserver o Source #

An Observer that schedules the observations to an effectful callback.

spawnCallbackObserver :: forall o r q. (SetMember Process (Process q) r, Typeable o, Show (Observation o), Observable o, Member (Logs LogMessage) q, Member Interrupts r, HasCallStack) => SchedulerProxy q -> (Server o -> Observation o -> Eff (InterruptableProcess q) ApiServerCmd) -> Eff r (Server (CallbackObserver o)) Source #

Start a new process for an Observer that schedules all observations to an effectful callback.

spawnLoggingObserver :: forall o r q. (SetMember Process (Process q) r, Typeable o, Show (Observation o), Observable o, Member (Logs LogMessage) q, Member (Logs LogMessage) r, Member Interrupts r, HasCallStack) => SchedulerProxy q -> Eff r (Server (CallbackObserver o)) Source #

Start a new process for an Observer that schedules all observations to an effectful callback.

Since: 0.3.0.0