[Haskell-beginners] optimisation of code
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Sep 21 08:25:20 UTC 2018
Hello,
I would like to have your advice in order to optimize this code.
The purpose is to trigg an action 'a' if a list of files (thousands) exists.
A process copy files from one directory to another.
allFilesThere :: MonadIO m => [Path Abs File] -> m Bool
allFilesThere fs = liftIO $ allM (doesFileExist . fromAbsFile) fs
trigOnAllFiles :: MonadIO m => m r -> [Path Abs File] -> m r
trigOnAllFiles a fs = go
where
go = do
r <- allFilesThere fs
if r then a else
( do liftIO $ threadDelay 1000000
go)
It works, but it consums a lot's of resources when all the files does not exists yet.
So I would like your advice in order to optimize it :)
thanks for your help.
Frederic
More information about the Beginners
mailing list