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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Api.Observer

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

Documentation

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

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

Minimal complete definition

observationMessage

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 a 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

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

manageObservers :: Eff (State (Observers 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 (State (Observers o)) r) => SchedulerProxy q -> Observation o -> Eff r () Source #

Send an Observation to all SomeObservers in the Observers state.

spawnCallbackObserver :: forall o r q. (SetMember Process (Process q) r, Typeable o, Show (Observation o), Observable o, Member (Logs String) q) => SchedulerProxy q -> (Server o -> Observation o -> Eff (Process q ': q) Bool) -> 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 String) q) => SchedulerProxy q -> Eff r (Server (CallbackObserver o)) Source #

Use spawnCallbackObserver to create a universal logging observer, using the Show instance of the Observation. | Start a new process for an Observer that schedules all observations to an effectful callback.

Since: 0.3.0.0