This is an internal module, meaning that it is unsafe to import unless you understand the risks.
This module provides the fast proxy implementation, which achieves its speed by weakening the monad transformer laws. These laws do not hold if you can pattern match on the constructors, as the following counter-example illustrates:
lift . return = M . return . Pure return = Pure lift . return /= return
The monad transformer laws do hold when viewed through the safe API exported from Control.Proxy.
Also, you really should not use the constructors anyway, let alone the
concrete type and instead you should stick to the
Proxy type class API.
This not only ensures that your code does not violate the monad transformer
laws, but also guarantees that it works with the other proxy implementations
and with any proxy transformers.
- data ProxyFast a' a b' b m r
- runProxy :: Monad m => (() -> ProxyFast a' () () b m r) -> m r
- runProxyK :: Monad m => (q -> ProxyFast a' () () b m r) -> q -> m r
- observe :: Monad m => ProxyFast a' a b' b m r -> ProxyFast a' a b' b m r
ProxyFast communicates with an upstream interface and a downstream
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
|Request a' (a -> ProxyFast a' a b' b m r)|
|Respond b (b' -> ProxyFast a' a b' b m r)|
|M (m (ProxyFast a' a b' b m r))|
|MFunctor (ProxyFast a' a b' b)|
|MonadTrans (ProxyFast a' a b' b)|
Only satisfies monad transformer laws modulo
|Monad m => Monad (ProxyFast a' a b' b m)|
|Monad m => Functor (ProxyFast a' a b' b m)|
|Monad m => Applicative (ProxyFast a' a b' b m)|
|MonadIO m => MonadIO (ProxyFast a' a b' b m)|
The following commands run self-sufficient proxies, converting them back to the base monad.
Run a self-sufficient
ProxyFast Kleisli arrow, converting it back to the
Run a self-sufficient
ProxyFast Kleisli arrow, converting it back to a
Kleisli arrow in the base monad
The monad transformer laws are correct when viewed through the
observe (lift (return r)) = observe (return r) observe (lift (m >>= f)) = observe (lift m >>= lift . f)
This correctness comes at a moderate cost to performance, so use this function sparingly or else you would be better off using Control.Proxy.Core.Correct.
You do not need to use this function if you use the safe API exported from Control.Proxy, which does not export any functions or constructors that can violate the monad transformer laws.