summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-12 06:46:58 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-12 06:46:58 +0400
commit5ee611585e4eb6acb89b34e6679d89e25098e23b (patch)
tree2ce638efe2782efc1559d82e859abf1129d34aad /examples
parentee8c82ed5ba8be43d858fa28020cc249d21795f6 (diff)
- Remove Extractable class, fix multi param methods.
Diffstat (limited to 'examples')
-rw-r--r--examples/Client.hs7
-rw-r--r--examples/Server.hs8
-rw-r--r--examples/Shared.hs19
3 files changed, 29 insertions, 5 deletions
diff --git a/examples/Client.hs b/examples/Client.hs
index 1d925c7a..cd340a03 100644
--- a/examples/Client.hs
+++ b/examples/Client.hs
@@ -10,7 +10,12 @@ addr :: RemoteAddr
10addr = (0, 6000) 10addr = (0, 6000)
11 11
12main :: IO () 12main :: IO ()
13main = print =<< call addr swapM (1, 2) 13main = do
14 print =<< call addr unitM ()
15 print =<< call addr echoM 0
16 call addr reverseM [1..1000]
17 print =<< call addr swapM (0, 1)
18 print =<< call addr shiftR ((), 1, [2..10])
14 19
15{- 20{-
16 forM_ [1..] $ const $ do 21 forM_ [1..] $ const $ do
diff --git a/examples/Server.hs b/examples/Server.hs
index 3760b2ab..0407c304 100644
--- a/examples/Server.hs
+++ b/examples/Server.hs
@@ -6,4 +6,10 @@ import Shared
6 6
7 7
8main :: IO () 8main :: IO ()
9main = server 6000 [swapM ==> \(a, b) -> return (b, a)] 9main = server 6000
10 [ unitM ==> return
11 , echoM ==> return
12 , swapM ==> \(a, b) -> return (b, a)
13 , reverseM ==> return . reverse
14 , shiftR ==> \(a, b, c) -> return (c, a, b)
15 ]
diff --git a/examples/Shared.hs b/examples/Shared.hs
index 49cef490..2d5b9cbb 100644
--- a/examples/Shared.hs
+++ b/examples/Shared.hs
@@ -1,14 +1,27 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2module Shared (echoInt, swapM) where 2module Shared
3 (echoM, unitM, swapM, reverseM, shiftR
4 ) where
3 5
4import Remote.KRPC 6import Remote.KRPC
5 7
6echoInt :: Method Int Int 8unitM :: Method () ()
7echoInt = idM 9unitM = method "unit" [] []
10
11echoM :: Method Int Int
12echoM = method "echo" ["x"] ["x"]
13
14reverseM :: Method [Int] [Int]
15reverseM = method "reverse" ["xs"] ["ys"]
8 16
9swapM :: Method (Int, Int) (Int, Int) 17swapM :: Method (Int, Int) (Int, Int)
10swapM = method "swap" ["x", "y"] ["b", "a"] 18swapM = method "swap" ["x", "y"] ["b", "a"]
11 19
20shiftR :: Method ((), Int, [Int]) ([Int], (), Int)
21shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"]
22
23
24
12{- 25{-
13type NodeId = Int 26type NodeId = Int
14type InfoHashe = Int 27type InfoHashe = Int