Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type EventConsumer e = Scoped_ (Consume e)
- interpretConsumeChan :: forall e r. Member (Embed IO) r => OutChan e -> InterpreterFor (Consume e) r
- interpretEventsInChan :: forall e r. Member (Embed IO) r => InChan e -> InterpreterFor (Events e) r
- interpretEventsChan :: forall e r. Members [Resource, Race, Async, Embed IO] r => InterpretersFor [Events e, EventConsumer e] r
Documentation
type EventConsumer e = Scoped_ (Consume e) Source #
Convenience alias for the consumer effect.
interpretConsumeChan :: forall e r. Member (Embed IO) r => 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 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. Members [Resource, Race, Async, Embed IO] r => InterpretersFor [Events e, EventConsumer 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
.