From 91575c31eb688bc033a9e0888c28ecd1badce6ae Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 6 Mar 2012 23:53:33 +0200
Subject: [PATCH] Replace explicit case with 'either'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Instead of manually case-ing on the Either contents, let's just use
either with const functions (not really readable, but…).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htools/Ganeti/HTools/Cluster.hs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index b47162332..1687a13bd 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -999,11 +999,9 @@ evacOneNodeInner :: Node.List         -- ^ Cluster node list
                  -> EvacInnerState    -- ^ New best solution
 evacOneNodeInner nl inst gdx op_fn accu ndx =
   case applyMove nl inst (op_fn ndx) of
-    OpFail fm ->
-      case accu of
-        Right _ -> accu
-        Left _ -> Left $ "Node " ++ Container.nameOf nl ndx ++
-                  " failed: " ++ show fm
+    OpFail fm -> let fail_msg = "Node " ++ Container.nameOf nl ndx ++
+                                " failed: " ++ show fm
+                 in either (const $ Left fail_msg) (const accu) accu
     OpGood (nl', inst', _, _) ->
       let nodes = Container.elems nl'
           -- The fromJust below is ugly (it can fail nastily), but
-- 
GitLab