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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Observer

Description

Observer Effects

This module supports the implementation of observers and observables. One more concrete perspective might be to understand observers as event listeners and observables as event sources. The tools in this module are tailored towards Api endpoints

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. (Observable o, Member MessagePassing r, Member Process r, Member (State (Observers o)) r) => Observation o -> Eff r () Source #

Send an Observation to all SomeObservers in the Observers state.

data CallbackObserver o Source #

An Observer that dispatches the observations to an effectful callback.

spawnCallbackObserver :: forall o r. (HasDispatcherIO r, Typeable o, Show (Observation o), Observable o) => (Server o -> Observation o -> Eff ProcIO Bool) -> Eff r (Server (CallbackObserver o)) Source #

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