Copyright | Aleksandr Krupenkin 2016-2018 |
---|---|
License | Apache-2.0 |
Maintainer | mail@akru.me |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Tiny JSON-RPC 2.0 client. Functions for implementing the client side of JSON-RPC 2.0. See http://www.jsonrpc.org/specification.
If you have monad with MonadIO
, MonadThrow
and MonadReader
instances,
it can be used as base for JSON-RPC calls.
Example:
newtype MyMonad a = ... instance JsonRpc MyMonad foo :: Mymonad Text foo = remote "foo"
Arguments of function are stored into params
request array.
Example:
myMethod :: JsonRpc m => Int -> Bool -> m String myMethod = remote "myMethod"
Synopsis
- class JsonRpcM m => JsonRpc m where
- remote :: Remote m a => MethodName -> a
- type MethodName = Text
- data JsonRpcClient
- = JsonRpcHttpClient { }
- | JsonRpcWsClient { }
- defaultSettings :: MonadIO m => String -> m JsonRpcClient
- data JsonRpcException
- data RpcError = RpcError {}
The JSON-RPC remote call monad
class JsonRpcM m => JsonRpc m where Source #
JSON-RPC call monad.
Nothing
remote :: Remote m a => MethodName -> a Source #
Remote call of JSON-RPC method.
type MethodName = Text Source #
Name of called method.
JSON-RPC client settings
data JsonRpcClient Source #
JSON-RPC client state vars.
JsonRpcHttpClient | |
| |
JsonRpcWsClient | |
|
Instances
Show JsonRpcClient Source # | |
Defined in Network.JsonRpc.TinyClient showsPrec :: Int -> JsonRpcClient -> ShowS # show :: JsonRpcClient -> String # showList :: [JsonRpcClient] -> ShowS # |
:: MonadIO m | |
=> String | JSON-RPC server URI |
-> m JsonRpcClient |
Create default JsonRpcClient
settings.
Error handling
data JsonRpcException Source #
Instances
Eq JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient (==) :: JsonRpcException -> JsonRpcException -> Bool # (/=) :: JsonRpcException -> JsonRpcException -> Bool # | |
Show JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient showsPrec :: Int -> JsonRpcException -> ShowS # show :: JsonRpcException -> String # showList :: [JsonRpcException] -> ShowS # | |
Exception JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient |