Prefer using pointfree style, remove unnecessary parentheses. There is a bug in hlint (https://github.com/ndmitchell/hlint/issues/196) that turns the "role" indentifier into a keyword. It can be disabled using -XNoRoleAnnotations but this flag is not supported by ghc 7.4.x which is distributed with wheezy. It could be worked around by detecting ghc version in automake.am, but a much simpler solution is to avoid using this identifier.
Signed-off-by: Viktor Bachraty <[email protected]> --- src/Ganeti/Confd/Server.hs | 18 +++++++++--------- src/Ganeti/Config.hs | 10 +++++----- src/Ganeti/Query/Node.hs | 4 ++-- src/Ganeti/UDSServer.hs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Ganeti/Confd/Server.hs b/src/Ganeti/Confd/Server.hs index 774054b..8eb9182 100644 --- a/src/Ganeti/Confd/Server.hs +++ b/src/Ganeti/Confd/Server.hs @@ -104,13 +104,13 @@ nodeRole :: ConfigData -> String -> Result ConfdNodeRole nodeRole cfg name = do cmaster <- errToResult $ QCluster.clusterMasterNodeName cfg mnode <- errToResult $ getNode cfg name - let role = case mnode of - node | cmaster == name -> NodeRoleMaster - | nodeDrained node -> NodeRoleDrained - | nodeOffline node -> NodeRoleOffline - | nodeMasterCandidate node -> NodeRoleCandidate - _ -> NodeRoleRegular - return role + let nrole = case mnode of + node | cmaster == name -> NodeRoleMaster + | nodeDrained node -> NodeRoleDrained + | nodeOffline node -> NodeRoleOffline + | nodeMasterCandidate node -> NodeRoleCandidate + _ -> NodeRoleRegular + return nrole -- | Does an instance ip -> instance -> primary node -> primary ip -- transformation. @@ -170,8 +170,8 @@ buildResponse cdata req@(ConfdRequest { confdRqType = ReqNodeRoleByName }) = do node_name <- case confdRqQuery req of PlainQuery str -> return str _ -> fail $ "Invalid query type " ++ show (confdRqQuery req) - role <- nodeRole (fst cdata) node_name - return (ReplyStatusOk, J.showJSON role, + nrole <- nodeRole (fst cdata) node_name + return (ReplyStatusOk, J.showJSON nrole, clusterSerial . configCluster $ fst cdata) buildResponse cdata (ConfdRequest { confdRqType = ReqNodePipList }) = diff --git a/src/Ganeti/Config.hs b/src/Ganeti/Config.hs index d908188..cf2f885 100644 --- a/src/Ganeti/Config.hs +++ b/src/Ganeti/Config.hs @@ -289,7 +289,7 @@ getInstance cfg name = getInstanceByName :: ConfigData -> String -> ErrorResult Instance getInstanceByName cfg name = let instances = M.elems . fromContainer . configInstances $ cfg - matching = F.find (\i -> maybe False (== name) (instName i)) instances + matching = F.find (maybe False (== name) . instName) instances in case matching of Just inst -> Ok inst Nothing -> Bad $ OpPrereqError @@ -491,9 +491,9 @@ getInstMinorsForNode :: ConfigData -> Instance -> [(String, Int, String, String, String, String)] getInstMinorsForNode cfg node inst = - let role = if Just node == instPrimaryNode inst - then rolePrimary - else roleSecondary + let nrole = if Just node == instPrimaryNode inst + then rolePrimary + else roleSecondary iname = fromMaybe "" $ instName inst inst_disks = case getInstDisksFromObj cfg inst of Ok disks -> disks @@ -502,7 +502,7 @@ getInstMinorsForNode cfg node inst = -- separate place, or reuse the iv_name (but that is deprecated on -- the Python side) in concatMap (\(idx, dsk) -> - [(node, minor, iname, "disk/" ++ show idx, role, peer) + [(node, minor, iname, "disk/" ++ show idx, nrole, peer) | (minor, peer) <- getDrbdMinorsForNode node dsk]) . zip [(0::Int)..] $ inst_disks diff --git a/src/Ganeti/Query/Node.hs b/src/Ganeti/Query/Node.hs index dc78785..3027fdc 100644 --- a/src/Ganeti/Query/Node.hs +++ b/src/Ganeti/Query/Node.hs @@ -171,8 +171,8 @@ nodeRoleDoc :: String nodeRoleDoc = "Node role; " ++ intercalate ", " - (map (\role -> - "\"" ++ nodeRoleToRaw role ++ "\" for " ++ roleDescription role) + (map (\nrole -> + "\"" ++ nodeRoleToRaw nrole ++ "\" for " ++ roleDescription nrole) (reverse [minBound..maxBound])) -- | Get node powered status. diff --git a/src/Ganeti/UDSServer.hs b/src/Ganeti/UDSServer.hs index 31f2f6c..d1236c9 100644 --- a/src/Ganeti/UDSServer.hs +++ b/src/Ganeti/UDSServer.hs @@ -293,7 +293,7 @@ sendMsg s buf = withTimeout (sendTmo $ clientConfig s) "sending a message" $ do B.hPut handle bEOM hFlush handle t2 <- getCurrentTimeUSec - logDebug $ "sendMsg: " ++ (show ((t2 - t1) `div` 1000)) ++ "ms" + logDebug $ "sendMsg: " ++ show ((t2 - t1) `div` 1000) ++ "ms" -- | Given a current buffer and the handle, it will read from the -- network until we get a full message, and it will return that -- 2.8.0.rc3.226.g39d4020
