| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Conduit.Process.Typed
Description
The System.Process.Typed module from typed-process, but with
added conduit helpers.
Synopsis
- createSink :: forall (m :: Type -> Type) o. MonadIO m => StreamSpec 'STInput (ConduitM ByteString o m ())
- createSinkClose :: forall (m :: Type -> Type) o. MonadIO m => StreamSpec 'STInput (ConduitM ByteString o m ())
- createSource :: forall (m :: Type -> Type) i. MonadIO m => StreamSpec 'STOutput (ConduitM i ByteString m ())
- withLoggedProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> (Process stdin (ConduitM () ByteString m ()) (ConduitM () ByteString m ()) -> m a) -> m a
- data ExitCode
- setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- data StdStream
- createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle
- type Pid = CPid
- proc :: FilePath -> [String] -> ProcessConfig () () ()
- shell :: String -> ProcessConfig () () ()
- readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString)
- getPid :: Process stdin stdout stderr -> IO (Maybe Pid)
- runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode
- checkExitCode :: MonadIO m => Process stdin stdout stderr -> m ()
- runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m ()
- readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString)
- data ByteStringOutputException = ByteStringOutputException SomeException (ProcessConfig () () ())
- data ExitCodeException = ExitCodeException {
- eceExitCode :: ExitCode
- eceProcessConfig :: ProcessConfig () () ()
- eceStdout :: ByteString
- eceStderr :: ByteString
- data StreamSpec (streamType :: StreamType) a
- data StreamType
- data ProcessConfig stdin stdout stderr
- setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr
- setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr
- setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr
- setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setDetachConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setCreateNewConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setChildGroup :: GroupID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setChildGroupInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setChildUser :: UserID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setChildUserInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a
- mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a
- inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- nullStream :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- byteStringInput :: ByteString -> StreamSpec 'STInput ()
- byteStringOutput :: StreamSpec 'STOutput (STM ByteString)
- useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- data Process stdin stdout stderr
- startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr)
- stopProcess :: MonadIO m => Process stdin stdout stderr -> m ()
- withProcessTerm :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcessWait :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcessTerm_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString)
- readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString
- readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString)
- readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString
- readProcessInterleaved :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString)
- readProcessInterleaved_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m ByteString
- waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode
- waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode
- getExitCode :: MonadIO m => Process stdin stdout stderr -> m (Maybe ExitCode)
- getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode)
- checkExitCodeSTM :: Process stdin stdout stderr -> STM ()
- getStdin :: Process stdin stdout stderr -> stdin
- getStdout :: Process stdin stdout stderr -> stdout
- getStderr :: Process stdin stdout stderr -> stderr
- unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle
- exitCodeExceptionWithOutput :: MonadIO m => Process stdin (STM ByteString) (STM ByteString) -> m ExitCodeException
- exitCodeExceptionNoOutput :: Process stdin stdout stderr -> ExitCode -> ExitCodeException
Conduit specific stuff
createSink :: forall (m :: Type -> Type) o. MonadIO m => StreamSpec 'STInput (ConduitM ByteString o m ()) Source #
Provide input to a process by writing to a conduit. The sink provided here
will leave the pipe to the child open after the stream ends. This allows the
sink to be used multiple times, but may result in surprising behavior. You
may prefer createSinkClose, see
https://github.com/snoyberg/conduit/issues/434.
Since: 1.2.1
createSinkClose :: forall (m :: Type -> Type) o. MonadIO m => StreamSpec 'STInput (ConduitM ByteString o m ()) Source #
Like createSink, but closes the pipe to the child process as soon as it
runs out of data.
Since: 1.3.5
createSource :: forall (m :: Type -> Type) i. MonadIO m => StreamSpec 'STOutput (ConduitM i ByteString m ()) Source #
Read output from a process by read from a conduit.
Since: 1.2.1
Running a process with logging
withLoggedProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> (Process stdin (ConduitM () ByteString m ()) (ConduitM () ByteString m ()) -> m a) -> m a Source #
Run a process, throwing an exception on a failure exit code. This will store all output from stdout and stderr in memory for better error messages. Note that this will require unbounded memory usage, so caveat emptor.
This will ignore any previous settings for the stdout and stderr
streams, and instead force them to use createSource.
Since: 1.2.3
Reexports
Defines the exit codes that a program can return.
Constructors
| ExitSuccess | indicates successful termination; |
| ExitFailure Int | indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system). |
Instances
setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
Constructors
| Inherit | Inherit Handle from parent |
| UseHandle Handle | Use the supplied Handle |
| CreatePipe | Create a new pipe. The returned
|
| NoStream | Close the stream's file descriptor without
passing a Handle. On POSIX systems this may
lead to strange behavior in the child process
because attempting to read or write after the
file has been closed throws an error. This
should only be used with child processes that
don't use the file descriptor at all. If you
wish to ignore the child process's output you
should either create a pipe and drain it
manually or pass a |
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle #
The platform specific type for a process identifier.
This is always an integral type. Width and signedness are platform specific.
Since: process-1.6.3.0
proc :: FilePath -> [String] -> ProcessConfig () () () #
shell :: String -> ProcessConfig () () () #
readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString) #
runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode #
checkExitCode :: MonadIO m => Process stdin stdout stderr -> m () #
runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m () #
readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString) #
data ByteStringOutputException #
Constructors
| ByteStringOutputException SomeException (ProcessConfig () () ()) |
Instances
data ExitCodeException #
Constructors
| ExitCodeException | |
Fields
| |
Instances
| Exception ExitCodeException | |
Defined in System.Process.Typed.Internal | |
| Show ExitCodeException | |
Defined in System.Process.Typed.Internal | |
data StreamSpec (streamType :: StreamType) a #
Instances
| Functor (StreamSpec streamType) | |
Defined in System.Process.Typed.Internal Methods fmap :: (a -> b) -> StreamSpec streamType a -> StreamSpec streamType b Source # (<$) :: a -> StreamSpec streamType b -> StreamSpec streamType a Source # | |
| (streamType ~ 'STInput, res ~ ()) => IsString (StreamSpec streamType res) | |
Defined in System.Process.Typed.Internal Methods fromString :: String -> StreamSpec streamType res Source # | |
data StreamType #
data ProcessConfig stdin stdout stderr #
Instances
| (stdin ~ (), stdout ~ (), stderr ~ ()) => IsString (ProcessConfig stdin stdout stderr) | |
Defined in System.Process.Typed.Internal Methods fromString :: String -> ProcessConfig stdin stdout stderr Source # | |
| Show (ProcessConfig stdin stdout stderr) | |
Defined in System.Process.Typed.Internal | |
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr #
setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr #
setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr #
setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setDetachConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setCreateNewConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setChildGroup :: GroupID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setChildGroupInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setChildUser :: UserID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setChildUserInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a #
mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a #
inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
nullStream :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
byteStringInput :: ByteString -> StreamSpec 'STInput () #
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () #
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () #
startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr) #
stopProcess :: MonadIO m => Process stdin stdout stderr -> m () #
withProcessTerm :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
withProcessWait :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
withProcessTerm_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #
readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString) #
readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString #
readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString) #
readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString #
readProcessInterleaved :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString) #
readProcessInterleaved_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m ByteString #
waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode #
waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode #
checkExitCodeSTM :: Process stdin stdout stderr -> STM () #
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle #
exitCodeExceptionWithOutput :: MonadIO m => Process stdin (STM ByteString) (STM ByteString) -> m ExitCodeException #
exitCodeExceptionNoOutput :: Process stdin stdout stderr -> ExitCode -> ExitCodeException #