On 2010-11-17 21:03, Peter Schmitz wrote:
> I am wondering how to generalize this to do likewise for a
> series of commands, where the varying args (filenames, in this
> case) are in a list ('inOutLeafs').The 'sequence' function is handy for combining a series of actions, such as [system cmd1, system cmd2, ...]. > I will also want to accumulate some results; probably just a > failure count at this time. 'sequence' hangs on to the results. That may be what you need. For control over accumulating results the good stuff is in Data.Foldable. > Any advice or pointers to examples would be much appreciated. > > Thanks in advance, > -- Peter > > >> run :: ... -> IO (Int) -- will return a fail count >> run >> -- some args to this function here... >> = do >> -- ... set up: inputLeafs, outputLeafs, etc. >> >> -- zip two lists of filenames: >> let inOutLeafs = zip inputLeafs outputLeafs >> >> -- the first pair for the first command: >> let (inFile1,outFile1) = head inOutLeafs >> >> -- build 1st command using 1st pair of filenames: >> let cmd1 = ... >> >> exitCode <- system cmd1 >> case (exitCode) of >> ExitSuccess -> do >> putStrLn $ "-- OK." >> return 0 >> ExitFailure failCnt -> do >> putStrLn $ "-- Failed: " ++ show failCnt >> return 1 > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
