-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Streaming support for running system process -- -- Stream data in and out of external commands. Configuration options are -- available to choose which inputs and outputs to use. @package streaming-process @version 0.1.0.0 -- | Run system commands in a streaming fashion. -- -- WARNING: If using this module, you will need to have -- ghc-options -threaded in your .cabal file otherwise -- it will likely hang! -- -- These functions are typically written to be used in a -- continuation-passing style to allow for proper finalisation. If you -- have many of these nested, it may be easier to use the -- Streaming.Process.Lifted module. -- -- These functions will all throw ProcessExitedUnsuccessfully if -- the process/command itself fails. module Streaming.Process -- | Feeds the provided data into the specified process, then concurrently -- streams stdout and stderr into the provided continuation. -- -- Note that the monad used in the StdOutErr argument to the -- continuation can be different from the final result, as it's up to the -- caller to make sure the result is reached. withStreamingProcess :: (MonadBaseControl IO m, MonadIO m, MonadMask m, MonadBase IO n) => CreateProcess -> ByteString m v -> (StdOutErr n () -> m r) -> m r -- | As with withStreamingProcess, but run the specified command in -- a shell. withStreamingCommand :: (MonadBaseControl IO m, MonadIO m, MonadMask m, MonadBase IO n) => String -> ByteString m v -> (StdOutErr n () -> m r) -> m r -- | Feed input into a process with no expected output. streamInput :: (MonadIO m, MonadMask m) => CreateProcess -> ByteString m r -> m r -- | As with streamInput but run the specified command in a shell. streamInputCommand :: (MonadIO m, MonadMask m) => String -> ByteString m r -> m r -- | Obtain the output of a process with no input (ignoring error output). withStreamingOutput :: (MonadIO n, MonadIO m, MonadMask m) => CreateProcess -> (ByteString n () -> m r) -> m r -- | As with withStreamingOutput but run the specified command in a -- shell. withStreamingOutputCommand :: (MonadIO n, MonadIO m, MonadMask m) => String -> (ByteString n () -> m r) -> m r -- | Represents the input and outputs for a streaming process. data StreamProcess stdin stdout stderr StreamProcess :: !stdin -> !stdout -> !stderr -> StreamProcess stdin stdout stderr [toStdin] :: StreamProcess stdin stdout stderr -> !stdin [fromStdout] :: StreamProcess stdin stdout stderr -> !stdout [fromStderr] :: StreamProcess stdin stdout stderr -> !stderr -- | Switch the two outputs. Useful for example if using -- withStreamProcess and withProcessHandles but wanting to -- deal with any potential output from stderr before stdout. switchOutputs :: StreamProcess stdin stdout stderr -> StreamProcess stdin stderr stdout -- | A wrapper for something taking a continuation with a stream of bytes -- as input. newtype WithStream n m WithStream :: (forall r. (ByteString n () -> m r) -> m r) -> WithStream n m [withStream] :: WithStream n m -> forall r. (ByteString n () -> m r) -> m r -- | An alias for the common case of n ~ m. type WithStream' m = WithStream m m -- | A wrapper for being able to provide a stream of bytes. newtype SupplyStream m SupplyStream :: (forall r. ByteString m r -> m r) -> SupplyStream m [supplyStream] :: SupplyStream m -> forall r. ByteString m r -> m r -- | A variant of withCheckedProcess that will on an exception kill -- the child process and attempt to perform cleanup (though you should -- also attempt to do so in your own code). -- -- Will throw ProcessExitedUnsuccessfully on a non-successful exit -- code. -- -- Compared to withCheckedProcessCleanup from -- conduit-extra, this has the three parameters grouped into -- StreamProcess to make it more of a continuation. withStreamProcess :: (InputSource stdin, OutputSink stdout, OutputSink stderr, MonadIO m, MonadMask m) => CreateProcess -> (StreamProcess stdin stdout stderr -> m r) -> m r -- | A variant of withStreamProcess that runs the provided command -- in a shell. withStreamCommand :: (InputSource stdin, OutputSink stdout, OutputSink stderr, MonadIO m, MonadMask m) => String -> (StreamProcess stdin stdout stderr -> m r) -> m r -- | Feeds the provided data into the input handle, then concurrently -- streams stdout and stderr into the provided continuation. -- -- Note that the monad used in the StdOutErr argument to the -- continuation can be different from the final result, as it's up to the -- caller to make sure the result is reached. withProcessHandles :: (MonadBaseControl IO m, MonadIO m, MonadMask m, MonadBase IO n) => ByteString m v -> StreamProcess (SupplyStream m) (WithStream' m) (WithStream' m) -> (StdOutErr n () -> m r) -> m r -- | Stream input into a process, ignoring any output. processInput :: (MonadIO m, MonadMask m) => StreamProcess (SupplyStream m) ClosedStream ClosedStream -> ByteString m r -> m r -- | Read the output from a process, ignoring stdin and stderr. withProcessOutput :: (MonadIO n, MonadIO m, MonadMask m) => StreamProcess ClosedStream (WithStream n m) ClosedStream -> (ByteString n () -> m r) -> m r -- | A representation of the concurrent streaming of both stdout -- and stderr (contrast to hGet). -- -- Note that if for example you wish to completely discard stderr, you -- can do so with hoist effects (or just process -- the stdout, then run effects at the end to discard the stderr). type StdOutErr m r = ByteString (ByteString m) r -- | Get both stdout and stderr concurrently. withStreamOutputs :: (MonadMask m, MonadIO m, MonadBaseControl IO m, MonadBase IO n) => StreamProcess stdin (WithStream' m) (WithStream' m) -> (StdOutErr n () -> m r) -> m r -- | Generalized version of concurrently. concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b) instance (GHC.Show.Show stderr, GHC.Show.Show stdout, GHC.Show.Show stdin) => GHC.Show.Show (Streaming.Process.StreamProcess stdin stdout stderr) instance (GHC.Classes.Eq stderr, GHC.Classes.Eq stdout, GHC.Classes.Eq stdin) => GHC.Classes.Eq (Streaming.Process.StreamProcess stdin stdout stderr) instance (Control.Monad.IO.Class.MonadIO m, Control.Monad.Catch.MonadMask m, Control.Monad.IO.Class.MonadIO n) => Data.Streaming.Process.Internal.OutputSink (Streaming.Process.WithStream n m) instance (Control.Monad.Catch.MonadMask m, Control.Monad.IO.Class.MonadIO m) => Data.Streaming.Process.Internal.InputSource (Streaming.Process.SupplyStream m) -- | This module defines variants of those in Streaming.Process for -- use with the Withable class, found in the -- streaming-with package. -- -- WARNING: If using this module, you will need to have -- ghc-options -threaded in your .cabal file otherwise -- it will likely hang! -- -- These functions will all throw ProcessExitedUnsuccessfully if -- the process/command itself fails. module Streaming.Process.Lifted -- | Feeds the provided data into the specified process, then concurrently -- streams stdout and stderr into the provided continuation. -- -- Note that the monad used in the StdOutErr argument to the -- continuation can be different from the final result, as it's up to the -- caller to make sure the result is reached. withStreamingProcess :: (Withable w, MonadBaseControl IO (WithMonad w), MonadBase IO n) => CreateProcess -> ByteString (WithMonad w) v -> w (StdOutErr n ()) -- | As with withStreamingProcess, but run the specified command in -- a shell. withStreamingCommand :: (Withable w, MonadBaseControl IO (WithMonad w), MonadBase IO n) => String -> ByteString (WithMonad w) v -> w (StdOutErr n ()) -- | Feed input into a process with no expected output. streamInput :: (Withable w) => CreateProcess -> ByteString (WithMonad w) r -> w r -- | As with streamInput but run the specified command in a shell. streamInputCommand :: (Withable w) => String -> ByteString (WithMonad w) r -> w r -- | Obtain the output of a process with no input (ignoring error output). withStreamingOutput :: (Withable w, MonadIO n) => CreateProcess -> w (ByteString n ()) -- | As with withStreamingOutput but run the specified command in a -- shell. withStreamingOutputCommand :: (Withable w, MonadIO n) => String -> w (ByteString n ()) -- | Represents the input and outputs for a streaming process. data StreamProcess stdin stdout stderr StreamProcess :: !stdin -> !stdout -> !stderr -> StreamProcess stdin stdout stderr [toStdin] :: StreamProcess stdin stdout stderr -> !stdin [fromStdout] :: StreamProcess stdin stdout stderr -> !stdout [fromStderr] :: StreamProcess stdin stdout stderr -> !stderr -- | Switch the two outputs. Useful for example if using -- withStreamProcess and withProcessHandles but wanting to -- deal with any potential output from stderr before stdout. switchOutputs :: StreamProcess stdin stdout stderr -> StreamProcess stdin stderr stdout -- | A wrapper for something taking a continuation with a stream of bytes -- as input. newtype WithStream n m WithStream :: (forall r. (ByteString n () -> m r) -> m r) -> WithStream n m -- | An alias for the common case of n ~ m. type WithStream' m = WithStream m m -- | Please note that - unlike the version in Streaming.Process - -- this is not a record selector. withStream :: (Withable w) => WithStream n (WithMonad w) -> w (ByteString n ()) -- | A wrapper for being able to provide a stream of bytes. newtype SupplyStream m SupplyStream :: (forall r. ByteString m r -> m r) -> SupplyStream m -- | Please note that - unlike the version in Streaming.Process - -- this is not a record selector. supplyStream :: (Withable w) => SupplyStream (WithMonad w) -> ByteString (WithMonad w) r -> w r -- | A variant of withCheckedProcess that will on an exception kill -- the child process and attempt to perform cleanup (though you should -- also attempt to do so in your own code). -- -- Will throw ProcessExitedUnsuccessfully on a non-successful exit -- code. -- -- Compared to withCheckedProcessCleanup from -- conduit-extra, this has the three parameters grouped into -- StreamProcess to make it more of a continuation. withStreamProcess :: (InputSource stdin, OutputSink stdout, OutputSink stderr, Withable w) => CreateProcess -> w (StreamProcess stdin stdout stderr) -- | A variant of withStreamProcess that runs the provided command -- in a shell. withStreamCommand :: (InputSource stdin, OutputSink stdout, OutputSink stderr, Withable w) => String -> w (StreamProcess stdin stdout stderr) -- | Feeds the provided data into the input handle, then concurrently -- streams stdout and stderr into the provided continuation. -- -- Note that the monad used in the StdOutErr argument to the -- continuation can be different from the final result, as it's up to the -- caller to make sure the result is reached. withProcessHandles :: (Withable w, m ~ WithMonad w, MonadBaseControl IO m, MonadBase IO n) => ByteString m v -> StreamProcess (SupplyStream m) (WithStream' m) (WithStream' m) -> w (StdOutErr n ()) -- | Stream input into a process, ignoring any output. processInput :: (Withable w) => StreamProcess (SupplyStream (WithMonad w)) ClosedStream ClosedStream -> ByteString (WithMonad w) r -> w r -- | Read the output from a process, ignoring stdin and stderr. withProcessOutput :: (Withable w, MonadIO n) => StreamProcess ClosedStream (WithStream n (WithMonad w)) ClosedStream -> w (ByteString n ()) -- | A representation of the concurrent streaming of both stdout -- and stderr (contrast to hGet). -- -- Note that if for example you wish to completely discard stderr, you -- can do so with hoist effects (or just process -- the stdout, then run effects at the end to discard the stderr). type StdOutErr m r = ByteString (ByteString m) r -- | Get both stdout and stderr concurrently. withStreamOutputs :: (Withable w, m ~ WithMonad w, MonadBaseControl IO m, MonadBase IO n) => StreamProcess stdin (WithStream' m) (WithStream' m) -> w (StdOutErr n ()) -- | Generalized version of concurrently. concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)