[Haskell-beginners] merge two handles

Manfred Lotz manfred.lotz at arcor.de
Tue Jun 14 17:26:55 CEST 2011


On Mon, 13 Jun 2011 15:14:26 -0500
Antoine Latter <aslatter at gmail.com> wrote:

> On Mon, Jun 13, 2011 at 1:14 PM, Manfred Lotz <manfred.lotz at arcor.de>
> wrote:
> > On Mon, 13 Jun 2011 12:51:02 -0500
> > Antoine Latter <aslatter at gmail.com> wrote:
> >
> >> On Mon, Jun 13, 2011 at 12:35 PM, Manfred Lotz
> >> <manfred.lotz at arcor.de> wrote:
> >> > Hi all,
> >> > I have two handles where I get stdout resp. stderr from a command
> >> > output.
> >> >
> >> >
> >> > Is it possible to merge those two handles so that I get a new
> >> > input handle in a way that data can be read from the new handle
> >> > whenever it is available from either of the two original handles?
> >> >
> >> >
> >>
> >> Does what you're doing strictly need to be a handle?
> >>
> >> One thing you could try is is using an IO Channel:
> >> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html
> >>
> >
> > Hmm, not quite sure. I was asking about handles because I use:
> >
> > (_ ,Just hout ,Just herr ,p) <- createProcess (proc cmd parms) {
> >    std_out = CreatePipe,
> >    std_err = CreatePipe
> >  }
> >
> >
> > which gives me handles to deal with.
> >
> 
> You could create the pipe yourself, and then call 'createProcess' with
> 'UseHandle' instead, passing the same handle to both std_out and
> std_error.
> 
> On a unix-y system you can do this with the functions in
> System.Posix.IO.
> 
> I'm not sure what you would do on windows. This might be a good

I'm on a Linux system. Don't use Windows.

Thanks for pointing to this. In the meantime I found something similar
in the online book "Real World Haskell". So I have something to try out.




-- 
Manfred





More information about the Beginners mailing list