remote-json-0.2: Remote Monad implementation of the JSON RPC protocol

Copyright(C) 2015, The University of Kansas
LicenseBSD-style (see the file LICENSE)
MaintainerJustin Dawson
Safe HaskellNone






The server RPC router

router :: MonadCatch m => (forall a. [m a] -> m [a]) -> (Call :~> m) -> ReceiveAPI :~> m Source

"The Server MAY process a batch rpc call as a set of concurrent tasks, processing them in any order and with any width of parallelism." We control this using the first argument.

The datatype that represents what we receive and what we dispatch

data ReceiveAPI :: * -> * where Source

The server-side recieived API. The user provides a way of dispatching this, to implement a server. An example of this using scotty is found in remote-json-server


Receive :: Value -> ReceiveAPI (Maybe Value) 


data Call :: * -> * where Source

Call is a user-visable deep embedding of a method or notification call. Server's provide transformations on this to implement remote-side call dispatching.


CallMethod :: Text -> Args -> Call Value 
CallNotification :: Text -> Args -> Call () 

Utilty methods

transport :: Monad f => (ReceiveAPI :~> f) -> SendAPI :~> f Source

transport connects the ability to recieve a message with the ability to send a message. Typically this is done using TCP/IP and HTTP, but we can simulate the connection here.

methodNotFound :: MonadThrow m => m a Source

Throw this exception when a 'JSONCall a -> IO a' fails to match a method or notification.

invalidParams :: MonadThrow m => m a Source

Throw this for when a 'JSONCall a -> IO a' method matches, but has invalid params.

parseError :: Value Source

For use when parsing to a JSON value fails inside a server, before calling the router