
On 2008 Oct 19, at 1:37, Stephen Hicks wrote:
I'm trying to understand how to get pipes working in Haskell, in particular with the revamped System.Process (though I've tried similar experiments with System.Posix.IO and Control.Concurrent). Specifically I'm trying to concatenate the output of two system calls into the input of a third. The following code does not get the job done:
Pipes are perhaps a bit misnamed: if you want to combine the output of two pipes and funnel it into a third you can't simply "plumb them together", you need to provide code which reads from the output pipes and writes into the input pipe. If you don't care about order, forkIO a thread for each output pipe which reads from the output pipe it's passed and writes to the input pipe. If order is significant, use mapM/forM to run the output-to-input code on each handle in turn. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH