From 0ae9ddc480badb4d44f43814db7b2910ad3e1beb Mon Sep 17 00:00:00 2001
From: Agata Murawska <agatamurawska@google.com>
Date: Thu, 27 Sep 2012 17:27:18 +0200
Subject: [PATCH] Merge parseHttpResponse with rpcResultParse

parseHttpResponse is such a simple function that we can actually
do the entire unpacking in rpcResultParse.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 htools/Ganeti/Rpc.hs | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/htools/Ganeti/Rpc.hs b/htools/Ganeti/Rpc.hs
index 7b41e45ce..625c7b67f 100644
--- a/htools/Ganeti/Rpc.hs
+++ b/htools/Ganeti/Rpc.hs
@@ -198,8 +198,9 @@ prepareHttpRequest node call
   | otherwise = Left $ OfflineNodeError node
 
 -- | Parse a result based on the received HTTP response.
-rpcResultParse :: (Rpc a b) => a -> String -> ERpcError b
-rpcResultParse call res =
+parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
+parseHttpResponse _ (Left err) = Left err
+parseHttpResponse call (Right res) =
   case J.decode res of
     J.Error val -> Left $ JsonDecodeError val
     J.Ok (True, res'') -> rpcResultFill call res''
@@ -207,11 +208,6 @@ rpcResultParse call res =
        J.JSString msg -> Left $ RpcResultError (J.fromJSString msg)
        _ -> Left . JsonDecodeError $ show (pp_value jerr)
 
--- | Parse the response or propagate the error.
-parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
-parseHttpResponse _ (Left err) = Left err
-parseHttpResponse call (Right response) = rpcResultParse call response
-
 -- | Execute RPC call for a sigle node.
 executeSingleRpcCall :: (Rpc a b) => Node -> a -> IO (Node, ERpcError b)
 executeSingleRpcCall node call = do
-- 
GitLab