Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A full tutorial for this module is available at: https://github.com/snoyberg/conduit/blob/master/PROCESS.md.
Some utilities in this module require the threaded runtime because they use
waitForProcess
internally.
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 -> ConduitT ByteString Void m a -> m (ExitCode, a)
- sourceProcessWithConsumer :: MonadIO m => CreateProcess -> ConduitT ByteString Void m a -> m (ExitCode, a)
- sourceCmdWithStreams :: MonadUnliftIO m => String -> ConduitT () ByteString m () -> ConduitT ByteString Void m a -> ConduitT ByteString Void m b -> m (ExitCode, a, b)
- sourceProcessWithStreams :: MonadUnliftIO m => CreateProcess -> ConduitT () ByteString m () -> ConduitT ByteString Void m a -> ConduitT ByteString Void m b -> m (ExitCode, a, b)
- withCheckedProcessCleanup :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadUnliftIO m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b
- newtype FlushInput o m r = FlushInput (ConduitM (Flush ByteString) o m r)
- newtype BuilderInput o m r = BuilderInput (ConduitM Builder o m r)
- module Data.Streaming.Process
Functions
sourceCmdWithConsumer Source #
Like sourceProcessWithConsumer
but providing the command to be run as
a String
.
Requires the threaded runtime.
Since 1.1.2
sourceProcessWithConsumer Source #
:: MonadIO m | |
=> CreateProcess | |
-> ConduitT ByteString Void 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.
Requires the threaded runtime.
Since 1.1.2
:: MonadUnliftIO m | |
=> String | command |
-> ConduitT () ByteString m () | stdin |
-> ConduitT ByteString Void m a | stdout |
-> ConduitT ByteString Void m b | stderr |
-> m (ExitCode, a, b) |
Like sourceProcessWithStreams
but providing the command to be run as
a String
.
Requires the threaded runtime.
Since: 1.1.12
sourceProcessWithStreams Source #
:: MonadUnliftIO m | |
=> CreateProcess | |
-> ConduitT () ByteString m () | stdin |
-> ConduitT ByteString Void m a | stdout |
-> ConduitT ByteString Void m b | stderr |
-> m (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
Requires the threaded runtime.
Since: 1.1.12
withCheckedProcessCleanup :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadUnliftIO m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b Source #
Same as withCheckedProcess
, but kills the child process in the case of
an exception being thrown by the provided callback function.
Requires the threaded runtime.
Since: 1.1.11
InputSource types
newtype FlushInput o m r Source #
Wrapper for input source which accepts Flush
es. Note that the pipe
will not automatically close then processing completes.
Since: 1.3.2
FlushInput (ConduitM (Flush ByteString) o m r) |
Instances
(MonadIO m, MonadIO n, r ~ (), r' ~ ()) => InputSource (FlushInput o m r, n r') Source # | |
Defined in Data.Conduit.Process isStdStream :: (Maybe Handle -> IO (FlushInput o m r, n r'), Maybe StdStream) # | |
(MonadIO m, r ~ ()) => InputSource (FlushInput o m r) Source # | |
Defined in Data.Conduit.Process isStdStream :: (Maybe Handle -> IO (FlushInput o m r), Maybe StdStream) # |
newtype BuilderInput o m r Source #
Wrapper for input source which accepts Builder
s.
You can pass flush
to flush the input. Note
that the pipe will not automatically close when the processing completes.
Since: 1.3.2
BuilderInput (ConduitM Builder o m r) |
Instances
(MonadIO m, MonadIO n, r ~ (), r' ~ ()) => InputSource (BuilderInput o m r, n r') Source # | |
Defined in Data.Conduit.Process isStdStream :: (Maybe Handle -> IO (BuilderInput o m r, n r'), Maybe StdStream) # | |
(MonadIO m, r ~ ()) => InputSource (BuilderInput o m r) Source # | |
Defined in Data.Conduit.Process isStdStream :: (Maybe Handle -> IO (BuilderInput o m r), Maybe StdStream) # |
Reexport
module Data.Streaming.Process
Orphan instances
(r ~ (), r' ~ (), MonadIO m, MonadIO n, i ~ ByteString) => InputSource (ConduitM i o m r, n r') Source # | |
(r ~ (), r' ~ (), MonadIO m, MonadIO n, o ~ ByteString) => OutputSink (ConduitM i o m r, n r') Source # | |
(r ~ (), MonadIO m, i ~ ByteString) => InputSource (ConduitM i o m r) Source # | |
(r ~ (), MonadIO m, o ~ ByteString) => OutputSink (ConduitM i o m r) Source # | |