I have a big IO function that will continuesly load data from a folder, perform pure calculations on the data, and write it back.
I am running this function over multiple folders in parallel using
mapConcurrently_ iofun folderList
This works perfecty... but a little bit too well. Now even the character output of the putStrLn
calls are async, which leads to an unreadable console log.
Is there a way to make IO Actions synchronized or even better a synchronized version of putStrLn?
The way you coordinate threads is via
MVar
s orTVar
s if you want to use STM. You can read all about them in "Parallel and Concurrent Haskell". You could do something like: