summaryrefslogtreecommitdiff
path: root/src/Remote
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-12 07:31:58 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-12 07:31:58 +0400
commita2bc26abbe6ccea464c04b990f8a4a8fa769ba2a (patch)
treea378e98388e02393e435a20335c6d1515da311b0 /src/Remote
parentfafdbec2cb64f11513bfe3a0a220562de97d9e36 (diff)
~ Move Method to KRPC.
Diffstat (limited to 'src/Remote')
-rw-r--r--src/Remote/KRPC.hs45
-rw-r--r--src/Remote/KRPC/Method.hs54
2 files changed, 42 insertions, 57 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 #-}
14module Remote.KRPC 14module 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
33import Network 39import Network
34 40
35import Remote.KRPC.Protocol 41import Remote.KRPC.Protocol
36import 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--
52data 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--
69idM :: Method a a
70idM = method "id" ["x"] ["y"]
71{-# INLINE idM #-}
72
73method :: MethodName -> [ParamName] -> [ValName] -> Method param result
74method = Method
75{-# INLINE method #-}
37 76
38 77
39data RPCException = RPCException KError 78data RPCException = RPCException KError
diff --git a/src/Remote/KRPC/Method.hs b/src/Remote/KRPC/Method.hs
deleted file mode 100644
index 4d91fe47..00000000
--- a/src/Remote/KRPC/Method.hs
+++ /dev/null
@@ -1,54 +0,0 @@
1-- |
2-- Copyright : (c) Sam T. 2013
3-- License : MIT
4-- Maintainer : pxqr.sta@gmail.com
5-- Stability : experimental
6-- Portability : portable
7--
8{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
10module Remote.KRPC.Method
11 ( Method(methodName, methodParams, methodVals)
12
13 -- * Construction
14 , method
15
16 -- * Predefined methods
17 , idM
18 ) where
19
20import Remote.KRPC.Protocol
21
22
23-- | The
24--
25-- * argument: type of method parameter
26--
27-- * remote: A monad used by server-side.
28--
29-- * result: type of return value of the method.
30--
31data Method param result = Method {
32 -- | Name used in query and
33 methodName :: MethodName
34
35 -- | Description of each parameter in /right to left/ order.
36 , methodParams :: [ParamName]
37
38 -- | Description of each return value in /right to left/ order.
39 , methodVals :: [ValName]
40 }
41
42-- TODO ppMethod
43
44-- | Remote identity function. Could be used for echo servers for example.
45--
46-- idM = method "id" ["x"] ["y"] return
47--
48idM :: Method a a
49idM = method "id" ["x"] ["y"]
50{-# INLINE idM #-}
51
52method :: MethodName -> [ParamName] -> [ValName] -> Method param result
53method = Method
54{-# INLINE method #-}