polysemy-conc-0.1.1.0: Polysemy Effects for Concurrency
Safe HaskellNone
LanguageHaskell2010

Polysemy.Conc.Interpreter.Events

Description

 
Synopsis

Documentation

interpretConsumeChan :: forall e r. Member (Embed IO) r => EventToken (OutChan e) -> InterpreterFor (Consume e) r Source #

Interpret Consume by reading from an OutChan. Used internally by interpretEventsChan, not safe to use directly.

interpretEventsInChan :: forall e r. Member (Embed IO) r => InChan e -> InterpreterFor (Events (OutChan e) e) r Source #

Interpret Events by writing to an InChan. Used internally by interpretEventsChan, not safe to use directly. When the channel queue is full, this silently discards events.

interpretEventsChan :: forall e r. Member (Embed IO) r => InterpretersFor [Events (OutChan e) e, Scoped (EventToken (OutChan e)) (Consume e)] r Source #

Interpret Events and Consume together by connecting them to the two ends of an unagi channel. Consume is only interpreted in a Scoped manner, ensuring that a new duplicate of the channel is created so that all consumers see all events (from the moment they are connected).

This should be used in conjunction with subscribe:

interpretEventsChan do
  async $ subscribe do
    putStrLn =<< consume
  publish "hello"

Whenever subscribe creates a new scope, this interpreter calls dupChan and passes the duplicate to interpretConsumeChan.