Safe Haskell | Safe-Inferred |
---|
This module provides the correct proxy implementation which strictly enforces the monad transformer laws. You can safely import this module without violating any laws or invariants.
However, I advise that you stick to the Proxy
type class API rather than
import this module so that your code works with both Proxy
implementations
and also works with all proxy transformers.
- data ProxyCorrect a' a b' b m r = Proxy {}
- data ProxyStep a' a b' b m r
- = Request a' (a -> ProxyCorrect a' a b' b m r)
- | Respond b (b' -> ProxyCorrect a' a b' b m r)
- | Pure r
- runProxy :: Monad m => (() -> ProxyCorrect a' () () b m r) -> m r
- runProxyK :: Monad m => (q -> ProxyCorrect a' () () b m r) -> q -> m r
Types
data ProxyCorrect a' a b' b m r Source
A ProxyCorrect
communicates with an upstream interface and a downstream
interface.
The type variables signify:
-
a'
- The request supplied to the upstream interface -
a
- The response provided by the upstream interface -
b'
- The request supplied by the downstream interface -
b
- The response provided to the downstream interface -
m
- The base monad -
r
- The final return value
ProxyInternal ProxyCorrect | |
Proxy ProxyCorrect | |
MFunctor (ProxyCorrect a' a b' b) | |
MonadTrans (ProxyCorrect a' a b' b) | |
Monad m => Monad (ProxyCorrect a' a b' b m) | |
Monad m => Functor (ProxyCorrect a' a b' b m) | |
Monad m => Applicative (ProxyCorrect a' a b' b m) | |
MonadIO m => MonadIO (ProxyCorrect a' a b' b m) |
data ProxyStep a' a b' b m r Source
The pure component of ProxyCorrect
Request a' (a -> ProxyCorrect a' a b' b m r) | |
Respond b (b' -> ProxyCorrect a' a b' b m r) | |
Pure r |
Run Sessions
The following commands run self-sufficient proxies, converting them back to the base monad.
These are the only functions specific to the ProxyCorrect
type.
Everything else programs generically over the Proxy
type class.
Use runProxyK
if you are running proxies nested within proxies. It
provides a Kleisli arrow as its result that you can pass to another
runProxy
/ runProxyK
command.
runProxy :: Monad m => (() -> ProxyCorrect a' () () b m r) -> m rSource
Run a self-sufficient ProxyCorrect
Kleisli arrow, converting it back to
the base monad
runProxyK :: Monad m => (q -> ProxyCorrect a' () () b m r) -> q -> m rSource
Run a self-sufficient ProxyCorrect
Kleisli arrow, converting it back to a
Kleisli arrow in the base monad