From 3cecd73ca063f20366d25eb04197ee79c2300f34 Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Mon, 8 Apr 2013 09:15:30 +0000 Subject: [PATCH] Backwards compatibility fix for Lucid The code introduced by the previous commit triggered a possible library conflict in Ubuntu Lucid. This patch introduces an equivalent but more widely acceptable version of the same code. Signed-off-by: Michele Tartara <mtartara@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- src/Ganeti/JQueue.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs index e439aa2fd..828e66251 100644 --- a/src/Ganeti/JQueue.hs +++ b/src/Ganeti/JQueue.hs @@ -230,9 +230,24 @@ determineJobDirectories rootdir archived = do else return [] return $ rootdir:other +-- Function equivalent to the \'sequence\' function, that cannot be used because +-- of library version conflict on Lucid. +-- FIXME: delete this and just use \'sequence\' instead when Lucid compatibility +-- will not be required anymore. +sequencer :: [Either IOError [JobId]] -> Either IOError [[JobId]] +sequencer l = fmap reverse $ foldl seqFolder (Right []) l + +-- | Folding function for joining multiple [JobIds] into one list. +seqFolder :: Either IOError [[JobId]] + -> Either IOError [JobId] + -> Either IOError [[JobId]] +seqFolder (Left e) _ = Left e +seqFolder (Right _) (Left e) = Left e +seqFolder (Right l) (Right el) = Right $ el:l + -- | Computes the list of all jobs in the given directories. getJobIDs :: [FilePath] -> IO (Either IOError [JobId]) -getJobIDs paths = liftM (fmap concat . sequence) (mapM getDirJobIDs paths) +getJobIDs paths = liftM (fmap concat . sequencer) (mapM getDirJobIDs paths) -- | Sorts the a list of job IDs. sortJobIDs :: [JobId] -> [JobId] -- GitLab