Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type ChanEvents e = Events (OutChan e) e
- type EventChan e = EventToken (OutChan e)
- type EventConsumer token e = Scoped (EventToken token) (Consume e)
- type ChanConsumer e = Scoped (EventChan e) (Consume e)
- interpretConsumeChan :: forall e r. Member (Embed IO) r => EventChan e -> InterpreterFor (Consume e) r
- interpretEventsInChan :: forall e r. Member (Embed IO) r => InChan e -> InterpreterFor (Events (OutChan e) e) r
- interpretEventsChan :: forall e r. Members [Resource, Race, Async, Embed IO] r => InterpretersFor [Events (OutChan e) e, ChanConsumer e] r
Documentation
type ChanEvents e = Events (OutChan e) e Source #
type EventChan e = EventToken (OutChan e) Source #
Convenience alias for the default EventToken
that uses an OutChan
.
type EventConsumer token e = Scoped (EventToken token) (Consume e) Source #
Convenience alias for the consumer effect.
type ChanConsumer e = Scoped (EventChan e) (Consume e) Source #
Convenience alias for the consumer effect using the default implementation.
interpretConsumeChan :: forall e r. Member (Embed IO) r => EventChan 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. Members [Resource, Race, Async, Embed IO] r => InterpretersFor [Events (OutChan e) e, ChanConsumer 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
.