diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs index e439aa2fd45cb5239c0597ec13fdda984f10cb1e..828e6625168baacadd8604d737068c6fdda79973 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]