Setting
I need to traverse a directory over 100+ .txt files, open every one and do some function on each, then combine the results. These files are huge, on the order of 10GB. Some common operation in psuedocode might be:
foldr concatFile mempty $ openFile <$> [filePath1, ..., filePathn]
foldr countStuff 0 $ openFile <$> [filePath1, ..., filePathn]
The trick is to make sure all the files never exist in memory at the same time, my previous naive solution created all kinds of swap files on my mac. In addition, if one of the filePath is invalid, I'd like to just skip over it and go on with the program.
My Solution
Currently I'm using conduit and would like to find a solution using conduit if possible. But if it's not the right tool I'm fine with using something else.
foldM
to process each, combining results along the way? – Aeriela