pipes-cliff - interact with subprocesses using Pipes

57 views
Skip to first unread message

Omari Norman

unread,
Mar 20, 2015, 12:42:57 PM3/20/15
to haskel...@googlegroups.com
Hi all,

I have created a library, pipes-cliff, for interacting with subprocesses using Pipes.


It aims to be simple and straightforward.  It's not as powerful as process-streaming--for instance you cannot combine standard output and standard error into the same stream (at least, not without doing the work yourself.)  It doesn't do ByteString to Text conversions.  But the API is (hopefully) easier to understand and works for the simple use cases that I need.

See also this previous thread for discussions of the various issues involved with streaming to and from subprocesses.


Feedback and bug reports welcome.  Thanks.  --Omari

Gabriel Gonzalez

unread,
Mar 20, 2015, 2:24:14 PM3/20/15
to haskel...@googlegroups.com, origin...@gmail.com
Awesome!  Thanks for doing this! :)

I was browsing the API and I just wanted to mention that you can simplify the constraints a little bit.  You have a couple of places where the constraint is:

    (MonadIO m, MonadSafe m) => ...

... and you can simplify that to just `MonadSafe m` because `MonadIO` is a super-class of `MonadSafe` in the latest versions of `pipes-safe`.
--
You received this message because you are subscribed to the Google Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-pipe...@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.

Daniel Díaz

unread,
Mar 20, 2015, 8:36:41 PM3/20/15
to haskel...@googlegroups.com
One doubt: when using pipeOutputError, is it possible to take the output and error producers and consume them concurrently in separate threads, for example using the Concurrently applicative from Control.Concurrent.Async?

Omari Norman

unread,
Mar 20, 2015, 9:16:38 PM3/20/15
to haskel...@googlegroups.com
On Fri, Mar 20, 2015 at 8:36 PM, Daniel Díaz <diaz.c...@gmail.com> wrote:
One doubt: when using pipeOutputError, is it possible to take the output and error producers and consume them concurrently in separate threads, for example using the Concurrently applicative from Control.Concurrent.Async?

Certainly you can consume them concurrently--in fact,  you would need to, or else the subprocess might block when its standard error or standard output fills up.  Each Producer returned by 'pipeOutputError' has an independent connection to the respective subprocess 'Handle'; concurrent threads will pull data from the subprocess and each 'Producer' will 'yield' its respective 'ByteString's.  You do, however, have to make sure that the 'Consumer' that you hook to the 'Producer' for stdout (or the 'fold' you want to run, or however you want to do it) runs concurrently with the ultimate 'Effect' that pulls from standard error.  There is a 'conveyor' function that makes it easy to run an 'Effect' in a background thread.

I will add an example to Pipes.Cliff.Examples showing how to pull from standard output and standard error.
Reply all
Reply to author
Forward
0 new messages