[Haskell-beginners] How to wait till a process is finished before invoking the next one?

Thomas Friedrich info at suud.de
Thu May 7 12:36:08 EDT 2009


Hi everyone,

I have the following problem, and I hope that someone of yours might be 
able to help me.

The Haskell program I am writing has the following setup:

writeData :: [String] -> IO ()
writeData cs = ...

runProgram:: [String] -> IO ()
runProgram cs = ...

writeFeatures :: [String] -> IO ()
writeFeatures cs = ...

runTestOnFeatures :: IO ()
runTestOnFeatures = ...

main :: IO ()
main = do
  cs <- getArgs
  writeData cs
  runProgram cs
  writeFeatures cs
  runTestOnFeatures

Each of the above function take a list of filenames, run certain 
command-line programs on them, which I invoke by runCommand, and each of 
them produce multiple output-files.  Each function in main needs a 
couple of those output-files that are produced by the function directly 
above it.  How do I get Haskell to wait, till all the data is written to 
the disk, before invoking the next command.  The way the program is 
currently written, Haskell doesn't see that the input of one function 
depends on the output of another, and tries to run them all at the same 
time.

Any ideas?

Thanks everyone for your help.

Cheers,
Thomas



More information about the Beginners mailing list