Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines Requester
, which indicates that an action can make
requests and receive responses to them. Typically, this is used for things
like a WebSocket, where it's desirable to collect many potential sources of
events and send them over a single channel, then distribute the results back
out efficiently to their original request sites.
Synopsis
- class (Reflex t, Monad m) => Requester t m | m -> t where
- type Request m :: * -> *
- type Response m :: * -> *
- requesting :: Event t (Request m a) -> m (Event t (Response m a))
- requesting_ :: Event t (Request m a) -> m ()
- withRequesting :: (Requester t m, MonadFix m) => (Event t (Response m a) -> m (Event t (Request m a), r)) -> m r
- requestingIdentity :: (Requester t m, Response m ~ Identity) => Event t (Request m a) -> m (Event t a)
Documentation
class (Reflex t, Monad m) => Requester t m | m -> t where Source #
A Requester
action can trigger requests of type Request m a
based on
Event
s, and receive responses of type Response m a
in return. Note that
the a
type can vary within the Requester
action, but will be linked for a
given request. For example, if Request m
is IO
and Response m
is
Identity
, then requestingIdentity
has the same type as
performEvent
.
type Request m :: * -> * Source #
The type of requests that this Requester
can emit
type Response m :: * -> * Source #
The type of responses that this Requester
can receive
requesting :: Event t (Request m a) -> m (Event t (Response m a)) Source #
requesting_ :: Event t (Request m a) -> m () Source #
Emit a request whenever the given Event
fires, and ignore all responses.