Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines the client monad and the type signatures for transports and prototocols.
- type JSONClient s m r = Client (s, Value) Value (ExceptT JSONClientError m) r
- type JSONClientError = (Value, Text, Value)
- call :: (ToJSON a, FromJSON r, Monad m) => s -> a -> JSONClient s m r
- type Protocol s m e = forall r. (s, Value) -> Proxy Value Value (s, Value) Value (ExceptT e m) r
- type Transport t m = MonadIO m => forall r. Value -> Server Value Value (t m) r
- runJSONClient :: (MonadTrans t, MFunctor t, MonadIO m, Monad (t m)) => Transport t m -> Protocol s m e -> JSONClient s m r -> t m (Either e (Either JSONClientError r))
- umap :: Monad m => (b' -> a') -> b' -> Proxy a' x b' x m r
- umapM :: Monad m => (b' -> m a') -> b' -> Proxy a' x b' x m r
- hoist :: MFunctor t => forall m b n. Monad m => (forall a. m a -> n a) -> t m b -> t n b
Client
type JSONClient s m r = Client (s, Value) Value (ExceptT JSONClientError m) r Source
type JSONClientError = (Value, Text, Value) Source
(request associated with the error, error message, response that caused the error)
Protocol
type Protocol s m e = forall r. (s, Value) -> Proxy Value Value (s, Value) Value (ExceptT e m) r Source
A bidirectional Proxy
waiting for a request, ready to be composed with +>>
or >+>
.
Protocol
s format incoming requests from downstream before sending them upstream. They also extract the values from returning protocol responses and send them downstream.
Protocol
s isolate clients from the specific details of each protocol.
Transport
Running clients
runJSONClient :: (MonadTrans t, MFunctor t, MonadIO m, Monad (t m)) => Transport t m -> Protocol s m e -> JSONClient s m r -> t m (Either e (Either JSONClientError r)) Source
Utils
These functions can be used to manipulate requests flowing upstream.