From 5ee611585e4eb6acb89b34e6679d89e25098e23b Mon Sep 17 00:00:00 2001 From: Sam T Date: Sun, 12 May 2013 06:46:58 +0400 Subject: - Remove Extractable class, fix multi param methods. --- examples/Client.hs | 7 ++++++- examples/Server.hs | 8 +++++++- examples/Shared.hs | 19 ++++++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'examples') 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 addr = (0, 6000) main :: IO () -main = print =<< call addr swapM (1, 2) +main = do + print =<< call addr unitM () + print =<< call addr echoM 0 + call addr reverseM [1..1000] + print =<< call addr swapM (0, 1) + print =<< call addr shiftR ((), 1, [2..10]) {- 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 main :: IO () -main = server 6000 [swapM ==> \(a, b) -> return (b, a)] +main = server 6000 + [ unitM ==> return + , echoM ==> return + , swapM ==> \(a, b) -> return (b, a) + , reverseM ==> return . reverse + , shiftR ==> \(a, b, c) -> return (c, a, b) + ] 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 @@ {-# LANGUAGE OverloadedStrings #-} -module Shared (echoInt, swapM) where +module Shared + (echoM, unitM, swapM, reverseM, shiftR + ) where import Remote.KRPC -echoInt :: Method Int Int -echoInt = idM +unitM :: Method () () +unitM = method "unit" [] [] + +echoM :: Method Int Int +echoM = method "echo" ["x"] ["x"] + +reverseM :: Method [Int] [Int] +reverseM = method "reverse" ["xs"] ["ys"] swapM :: Method (Int, Int) (Int, Int) swapM = method "swap" ["x", "y"] ["b", "a"] +shiftR :: Method ((), Int, [Int]) ([Int], (), Int) +shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"] + + + {- type NodeId = Int type InfoHashe = Int -- cgit v1.2.3