change Caller interface.

Ilya Portnov [2010-04-21 14:54:16]
change Caller interface.
Filename
Caller.hs
TestCall.hs
diff --git a/Caller.hs b/Caller.hs
index 0d7c404..47d1420 100644
--- a/Caller.hs
+++ b/Caller.hs
@@ -12,9 +12,13 @@ import YAML
 import YAMLInstances
 import Server

-call :: (IsYamlObject a, IsYamlObject b) => (String -> IO (String,Int)) -> String -> String -> a -> IO b
-call getServer service name args = withSocketsDo $ do
-  (host,port) <- getServer service
+callDynamic :: (IsYamlObject a, IsYamlObject b) => (String -> IO (String,Int)) -> String -> String -> a -> IO b
+callDynamic getServer service name args = do
+  srv <- getServer service
+  call srv name args
+
+call :: (IsYamlObject a, IsYamlObject b) => (String, Int) -> String -> a -> IO b
+call (host,port) name args = withSocketsDo $ do
   h <- connectTo host (PortNumber $ fromIntegral port)
   let c = mkCall name (cs args)
       s = serialize c
diff --git a/TestCall.hs b/TestCall.hs
index 76d9e27..723d93e 100644
--- a/TestCall.hs
+++ b/TestCall.hs
@@ -6,11 +6,12 @@ import YAML
 import YAMLInstances
 import Caller

-getServer "test" = return ("127.0.0.1", 5000)
-getServer _ = fail "Unknown service"
+getService "test" = return ("127.0.0.1", 5000)
+getService _ = fail "Unknown service"

 p = Point 2.0 3.0

 main = do
-  r <- call getServer "test" "double" p
+  srv <- getService "test"
+  r <- call srv "double" p
   print (r :: Point)
ViewGit