diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-05-12 06:46:58 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-05-12 06:46:58 +0400 |
commit | 5ee611585e4eb6acb89b34e6679d89e25098e23b (patch) | |
tree | 2ce638efe2782efc1559d82e859abf1129d34aad /examples | |
parent | ee8c82ed5ba8be43d858fa28020cc249d21795f6 (diff) |
- Remove Extractable class, fix multi param methods.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Client.hs | 7 | ||||
-rw-r--r-- | examples/Server.hs | 8 | ||||
-rw-r--r-- | examples/Shared.hs | 19 |
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 | |||
10 | addr = (0, 6000) | 10 | addr = (0, 6000) |
11 | 11 | ||
12 | main :: IO () | 12 | main :: IO () |
13 | main = print =<< call addr swapM (1, 2) | 13 | main = 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 | ||
8 | main :: IO () | 8 | main :: IO () |
9 | main = server 6000 [swapM ==> \(a, b) -> return (b, a)] | 9 | main = 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 #-} |
2 | module Shared (echoInt, swapM) where | 2 | module Shared |
3 | (echoM, unitM, swapM, reverseM, shiftR | ||
4 | ) where | ||
3 | 5 | ||
4 | import Remote.KRPC | 6 | import Remote.KRPC |
5 | 7 | ||
6 | echoInt :: Method Int Int | 8 | unitM :: Method () () |
7 | echoInt = idM | 9 | unitM = method "unit" [] [] |
10 | |||
11 | echoM :: Method Int Int | ||
12 | echoM = method "echo" ["x"] ["x"] | ||
13 | |||
14 | reverseM :: Method [Int] [Int] | ||
15 | reverseM = method "reverse" ["xs"] ["ys"] | ||
8 | 16 | ||
9 | swapM :: Method (Int, Int) (Int, Int) | 17 | swapM :: Method (Int, Int) (Int, Int) |
10 | swapM = method "swap" ["x", "y"] ["b", "a"] | 18 | swapM = method "swap" ["x", "y"] ["b", "a"] |
11 | 19 | ||
20 | shiftR :: Method ((), Int, [Int]) ([Int], (), Int) | ||
21 | shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"] | ||
22 | |||
23 | |||
24 | |||
12 | {- | 25 | {- |
13 | type NodeId = Int | 26 | type NodeId = Int |
14 | type InfoHashe = Int | 27 | type InfoHashe = Int |