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 <[email protected]>
---
 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 e439aa2..828e662 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]
-- 
1.8.1.3

Reply via email to