| Copyright | Alexander Krupenkin 2016-2018 |
|---|---|
| License | BSD3 |
| Maintainer | mail@akru.me |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.JsonRpc.TinyClient
Description
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.
Minimal complete definition
Nothing
Instances
| JsonRpc Web3 Source # | |
Defined in Network.Web3.Provider Methods remote :: Remote Web3 a => MethodName -> a Source # | |
type MethodName = Text Source #
Name of called method.
JSON-RPC client settings
data JsonRpcClient Source #
JSON-RPC client state vars.
Constructors
| JsonRpcHttpClient | |
Fields
| |
| JsonRpcWsClient | |
Fields
| |
Instances
| Show JsonRpcClient Source # | |
Defined in Network.JsonRpc.TinyClient Methods showsPrec :: Int -> JsonRpcClient -> ShowS # show :: JsonRpcClient -> String # showList :: [JsonRpcClient] -> ShowS # | |
| MonadState JsonRpcClient Web3 Source # | |
Defined in Network.Web3.Provider Methods get :: Web3 JsonRpcClient # put :: JsonRpcClient -> Web3 () # state :: (JsonRpcClient -> (a, JsonRpcClient)) -> Web3 a # | |
Arguments
| :: MonadIO m | |
| => String | JSON-RPC server URI |
| -> m JsonRpcClient |
Create default JsonRpcClient settings.
Error handling
data JsonRpcException Source #
Constructors
| ParsingException String | |
| CallException RpcError |
Instances
| Eq JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient Methods (==) :: JsonRpcException -> JsonRpcException -> Bool # (/=) :: JsonRpcException -> JsonRpcException -> Bool # | |
| Show JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient Methods showsPrec :: Int -> JsonRpcException -> ShowS # show :: JsonRpcException -> String # showList :: [JsonRpcException] -> ShowS # | |
| Exception JsonRpcException Source # | |
Defined in Network.JsonRpc.TinyClient Methods toException :: JsonRpcException -> SomeException # | |