conduit-extra-1.1.15: Batteries included conduit: adapters for common libraries.

Safe Haskell | None
Language | Haskell98

Data.Conduit.Process

Contents

- Functions
- Reexport
- Orphan instances

Description

A full tutorial for this module is available at: https://github.com/snoyberg/conduit/blob/master/PROCESS.md.

Note that this is a very thin layer around the `Data.Streaming.Process` module. In particular, it:

- Provides orphan instances for conduit
- Provides some useful helper functions

Synopsis

- sourceCmdWithConsumer :: MonadIO m => String -> Consumer ByteString m a -> m (ExitCode, a)
- sourceProcessWithConsumer :: MonadIO m => CreateProcess -> Consumer ByteString m a -> m (ExitCode, a)
- sourceCmdWithStreams :: String -> Producer IO ByteString -> Consumer ByteString IO a -> Consumer ByteString IO b -> IO (ExitCode, a, b)
- sourceProcessWithStreams :: CreateProcess -> Producer IO ByteString -> Consumer ByteString IO a -> Consumer ByteString IO b -> IO (ExitCode, a, b)
- withCheckedProcessCleanup :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadIO m, MonadMask m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b
- module Data.Streaming.Process

# Functions

sourceCmdWithConsumer #

Arguments

:: MonadIO m |
=> String | command
-> Consumer ByteString m a | stdout
-> m (ExitCode, a) |

Like `sourceProcessWithConsumer` but providing the command to be run as a `String`.

Since 1.1.2

sourceProcessWithConsumer #

Arguments

:: MonadIO m |
=> CreateProcess |
-> Consumer ByteString m a | stdout
-> m (ExitCode, a) |

Given a `CreateProcess`, run the process, with its output being used as a `Source` to feed the provided `Consumer`. Once the process has completed, return a tuple of the `ExitCode` from the process and the output collected from the `Consumer`.

Note that, if an exception is raised by the consumer, the process is not terminated. This behavior is different from `sourceProcessWithStreams` due to historical reasons.

Since 1.1.2

sourceCmdWithStreams #

Arguments

:: String | command
-> Producer IO ByteString | stdin
-> Consumer ByteString IO a | stdout
-> Consumer ByteString IO b | stderr
-> IO (ExitCode, a, b) |

Like `sourceProcessWithStreams` but providing the command to be run as a `String`.

Since: 1.1.12

sourceProcessWithStreams #

Arguments

:: CreateProcess |
-> Producer IO ByteString | stdin
-> Consumer ByteString IO a | stdout
-> Consumer ByteString IO b | stderr
-> IO (ExitCode, a, b) |

Given a `CreateProcess`, run the process and feed the provided `Producer` to the stdin `Sink` of the process. Use the process outputs (stdout, stderr) as `Source`s and feed it to the provided `Consumer`s. Once the process has completed, return a tuple of the `ExitCode` from the process and the results collected from the `Consumer`s.

If an exception is raised by any of the streams, the process is terminated.

IO is required because the streams are run concurrently using the async package

Since: 1.1.12

withCheckedProcessCleanup :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadIO m, MonadMask m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b #

Same as `withCheckedProcess`, but kills the child process in the case of an exception being thrown by the provided callback function.

Since: 1.1.11

# Reexport

module Data.Streaming.Process

# Orphan instances

((~) * r (), (~) * r' (), MonadIO m, MonadIO n, (~) * i ByteString) => InputSource (ConduitM i o m r, n r') # |
Methods isStdStream :: (Maybe Handle -> IO (ConduitM i o m r, n r'), Maybe StdStream) #
((~) * r (), (~) * r' (), MonadIO m, MonadIO n, (~) * o ByteString) => OutputSink (ConduitM i o m r, n r') # |
Methods osStdStream :: (Maybe Handle -> IO (ConduitM i o m r, n r'), Maybe StdStream) #
((~) * r (), MonadIO m, (~) * i ByteString) => InputSource (ConduitM i o m r) # |
Methods isStdStream :: (Maybe Handle -> IO (ConduitM i o m r), Maybe StdStream) #
((~) * r (), MonadIO m, (~) * o ByteString) => OutputSink (ConduitM i o m r) # |
Methods osStdStream :: (Maybe Handle -> IO (ConduitM i o m r), Maybe StdStream) #