diff options
Diffstat (limited to 'src/Remote/KRPC.hs')
-rw-r--r-- | src/Remote/KRPC.hs | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/src/Remote/KRPC.hs b/src/Remote/KRPC.hs index 5c1aadd6..ec83b802 100644 --- a/src/Remote/KRPC.hs +++ b/src/Remote/KRPC.hs | |||
@@ -5,14 +5,20 @@ | |||
5 | -- Stability : experimental | 5 | -- Stability : experimental |
6 | -- Portability : portable | 6 | -- Portability : portable |
7 | -- | 7 | -- |
8 | -- This module provides remote procedure call. | 8 | -- This module provides safe remote procedure call. |
9 | -- | 9 | -- |
10 | {-# LANGUAGE OverloadedStrings #-} | 10 | {-# LANGUAGE OverloadedStrings #-} |
11 | {-# LANGUAGE FlexibleContexts, DeriveDataTypeable #-} | 11 | {-# LANGUAGE FlexibleContexts, DeriveDataTypeable #-} |
12 | {-# LANGUAGE ExplicitForAll, KindSignatures #-} | 12 | {-# LANGUAGE ExplicitForAll, KindSignatures #-} |
13 | {-# LANGUAGE ViewPatterns #-} | 13 | {-# LANGUAGE ViewPatterns #-} |
14 | module Remote.KRPC | 14 | module Remote.KRPC |
15 | ( module Remote.KRPC.Method, RemoteAddr | 15 | ( -- * Common |
16 | -- ** Types | ||
17 | RemoteAddr | ||
18 | |||
19 | -- ** Method | ||
20 | , Method(methodName, methodParams, methodVals) | ||
21 | , method, idM | ||
16 | 22 | ||
17 | -- * Client | 23 | -- * Client |
18 | , call, async, await | 24 | , call, async, await |
@@ -33,7 +39,40 @@ import Data.Typeable | |||
33 | import Network | 39 | import Network |
34 | 40 | ||
35 | import Remote.KRPC.Protocol | 41 | import Remote.KRPC.Protocol |
36 | import Remote.KRPC.Method | 42 | |
43 | |||
44 | -- | The | ||
45 | -- | ||
46 | -- * argument: type of method parameter | ||
47 | -- | ||
48 | -- * remote: A monad used by server-side. | ||
49 | -- | ||
50 | -- * result: type of return value of the method. | ||
51 | -- | ||
52 | data Method param result = Method { | ||
53 | -- | Name used in query and | ||
54 | methodName :: MethodName | ||
55 | |||
56 | -- | Description of each parameter in /right to left/ order. | ||
57 | , methodParams :: [ParamName] | ||
58 | |||
59 | -- | Description of each return value in /right to left/ order. | ||
60 | , methodVals :: [ValName] | ||
61 | } | ||
62 | |||
63 | -- TODO ppMethod | ||
64 | |||
65 | -- | Remote identity function. Could be used for echo servers for example. | ||
66 | -- | ||
67 | -- idM = method "id" ["x"] ["y"] return | ||
68 | -- | ||
69 | idM :: Method a a | ||
70 | idM = method "id" ["x"] ["y"] | ||
71 | {-# INLINE idM #-} | ||
72 | |||
73 | method :: MethodName -> [ParamName] -> [ValName] -> Method param result | ||
74 | method = Method | ||
75 | {-# INLINE method #-} | ||
37 | 76 | ||
38 | 77 | ||
39 | data RPCException = RPCException KError | 78 | data RPCException = RPCException KError |