commit cf4942e3e8f28688437693f6afedc3f23035855c
Merge: 3b5c416 84cc5fc
Author: Brian Foley <[email protected]>
Date:   Wed Aug 17 11:02:01 2016 +0100

    Merge branch 'stable-2.16' into stable-2.17
    
    * stable-2.16
      Fix some typos/poor phrasing in gnt-node man page
      Add missing cluster modify --modify-etc-hosts to man
      Fix/quell hlint warnings
    
    Manually fix merge conflict in src/Ganeti/Utils.hs
    
    Signed-off-by: Brian Foley <[email protected]>

diff --cc src/Ganeti/Utils.hs
index 0c2a0ac,8a586d0..d061ec9
--- a/src/Ganeti/Utils.hs
+++ b/src/Ganeti/Utils.hs
@@@ -849,45 -820,7 +849,46 @@@ isSubsequenceOf _     [
  isSubsequenceOf a@(x:a') (y:b) | x == y    = isSubsequenceOf a' b
                                 | otherwise = isSubsequenceOf a b
  
 +-- | Compute the maximum of two elements by a given order.
 +-- As opposed to using `maximumBy`, is function is guaranteed
 +-- to be total, as the signature enforces a non-empty list of
 +-- arguments.
 +maxBy :: (a -> a -> Ordering) -> a -> a -> a
 +maxBy ord a b = maximumBy ord [a, b]
 +
 +-- | Given a predicate that is monotone on a list, find the
 +-- first list entry where it holds, if any. Use the monotonicity
 +-- property to evaluate the property at as few places as possible,
 +-- guided by the heuristics provided.
 +monotoneFind :: ([a] -> Int) -> (a -> Bool) -> [a] -> Maybe a
 +monotoneFind heuristics p xs =
 +  let count = heuristics xs
 +  in case () of
 +    _ | x:xs' <- drop count xs
 +        -> if p x
 +             then (`mplus` Just x) . monotoneFind heuristics p
 +                  $ take count xs
 +             else monotoneFind heuristics p xs'
 +    _ | x:xs' <- xs
 +        -> if p x
 +             then Just x
 +             else monotoneFind heuristics p xs'
 +    _ -> Nothing
 +
 +-- | Iterate a function as long as it returns Just values, collecting
 +-- all the Justs that where obtained.
 +iterateJust :: (a -> Maybe a) -> a -> [a]
 +iterateJust f a = a : maybe [] (iterateJust f) (f a)
 +
 +-- | A version of partition with a monadic predicate
 +-- Implementation taken from David Fox's Extras package.
 +partitionM :: (Monad m) => (a -> m Bool) -> [a] -> m ([a], [a])
 +partitionM p xs = foldM f ([], []) xs
 +  where f (a, b) x = do
 +        pv <- p x
 +        return $ if pv then (x : a, b) else (a, x : b)
 +
+ {-# ANN frequency "HLint: ignore Use alternative" #-}
  -- | Returns a list of tuples of elements and the number of times they occur
  -- in a list
  frequency :: Ord t => [t] -> [(Int, t)]

Reply via email to