[Haskell-cafe] Re: ANN: HSH 1.2.0

Simon Marlow simonmarhaskell at gmail.com
Tue Mar 13 06:51:47 EDT 2007


John Goerzen wrote:
> On 2007-03-06, Simon Marlow <simonmarhaskell at gmail.com> wrote:
>> John Goerzen wrote:
>>> possible to create a pipe going directly from program A to program B.
>> You certainly can pipe directly from one process to another:
> 
> That only works for 2 processes.  What if I have 4 processes, and want
> to pipe from one to the next, all along, as in
> 
> ls -l /tmp | tr a-zA-Z | sort | md5sum
> 
> to give a contrived example

Before I answer the question, if you don't mind I'll quote from my own message:

 > However, I'll accept that there are certain arrangements of pipes that
 > aren't possible, or will construct too many pipes and you'll need extra
 > threads to connect them together, because the only way to create pipes
 > is with runInteractive* and that creates pipes for all of
 > stdin/stdout/stderr.
 >
 > Of course we're open to suggestions for improving System.Process.
 > Perhaps there should be a version that lets you specify a Handle *or*
 > create a pipe, for each standard file descriptor.

So ideally we'd have a version of runInteractiveProcess that didn't create all 
three pipes, and then it would be easy to program your example.  Unfortunately 
we don't have such a function, but it's still possible to code up your example - 
you just end up with too many pipes and you'd need some Haskell threads to act 
as dummy "processes" between the extra pipe ends.  I'm aware this isn't a 
satisfactory solution, for various reasons.

Cheers,
	Simon



More information about the Haskell-Cafe mailing list