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
- proc :: FilePath -> [String] -> ProcessConfig () () ()
- data Process stdin stdout stderr
- data ExitCode
- = ExitSuccess
- | ExitFailure Int
- data StdStream
- = Inherit
- | UseHandle Handle
- | CreatePipe
- | NoStream
- shell :: String -> ProcessConfig () () ()
- getPid :: Process stdin stdout stderr -> IO (Maybe Pid)
- readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString)
- runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode
- createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle
- type Pid = CPid
- data StreamSpec (streamType :: StreamType) a
- data StreamType
- data 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
- getStdout :: Process stdin stdout stderr -> stdout
- getStderr :: Process stdin stdout stderr -> stderr
- checkExitCode :: MonadIO m => Process stdin stdout stderr -> m ()
- data ExitCodeException = ExitCodeException {
- eceExitCode :: ExitCode
- eceProcessConfig :: ProcessConfig () () ()
- eceStdout :: ByteString
- eceStderr :: ByteString
- data ByteStringOutputException = ByteStringOutputException SomeException (ProcessConfig () () ())
- byteStringInput :: ByteString -> StreamSpec 'STInput ()
- byteStringOutput :: StreamSpec 'STOutput (STM ByteString)
- closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a
- mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a
- nullStream :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()
- 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
- setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setCreateNewConsole :: 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
- setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr
- setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
- useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- withProcess_ :: 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
- startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr)
- checkExitCodeSTM :: Process stdin stdout stderr -> STM ()
- exitCodeExceptionNoOutput :: Process stdin stdout stderr -> ExitCode -> ExitCodeException
- exitCodeExceptionWithOutput :: MonadIO m => Process stdin (STM ByteString) (STM ByteString) -> m ExitCodeException
- getExitCode :: MonadIO m => Process stdin stdout stderr -> m (Maybe ExitCode)
- getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode)
- getStdin :: Process stdin stdout stderr -> stdin
- readProcessInterleaved :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString)
- readProcessInterleaved_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m ByteString
- readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString)
- readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString
- readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString)
- readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString
- readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString)
- runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m ()
- stopProcess :: MonadIO m => Process stdin stdout stderr -> m ()
- unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle
- waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode
- waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode
- withProcessTerm :: 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
- withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
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
proc :: FilePath -> [String] -> ProcessConfig () () () #
Constructors
ExitSuccess | |
ExitFailure Int |
Instances
Exception ExitCode | |||||
Defined in GHC.Internal.IO.Exception Methods toException :: ExitCode -> SomeException fromException :: SomeException -> Maybe ExitCode displayException :: ExitCode -> String backtraceDesired :: ExitCode -> Bool | |||||
Generic ExitCode | |||||
Defined in GHC.Internal.IO.Exception Associated Types
| |||||
Read ExitCode | |||||
Defined in GHC.Internal.IO.Exception | |||||
Show ExitCode | |||||
Eq ExitCode | |||||
Ord ExitCode | |||||
Defined in GHC.Internal.IO.Exception | |||||
type Rep ExitCode | |||||
Defined in GHC.Internal.IO.Exception type Rep ExitCode = D1 ('MetaData "ExitCode" "GHC.Internal.IO.Exception" "ghc-internal" 'False) (C1 ('MetaCons "ExitSuccess" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExitFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) |
Constructors
Inherit | |
UseHandle Handle | |
CreatePipe | |
NoStream |
shell :: String -> ProcessConfig () () () #
readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString) #
runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode #
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle #
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 (<$) :: a -> StreamSpec streamType b -> StreamSpec streamType a | |
(streamType ~ 'STInput, res ~ ()) => IsString (StreamSpec streamType res) | |
Defined in System.Process.Typed.Internal Methods fromString :: String -> StreamSpec streamType res |
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 | |
Show (ProcessConfig stdin stdout stderr) | |
Defined in System.Process.Typed.Internal Methods showsPrec :: Int -> ProcessConfig stdin stdout stderr -> ShowS show :: ProcessConfig stdin stdout stderr -> String showList :: [ProcessConfig stdin stdout stderr] -> ShowS |
setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr #
setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr #
checkExitCode :: MonadIO m => Process stdin stdout stderr -> m () #
data ExitCodeException #
Constructors
ExitCodeException | |
Fields
|
Instances
Exception ExitCodeException | |
Defined in System.Process.Typed.Internal Methods toException :: ExitCodeException -> SomeException fromException :: SomeException -> Maybe ExitCodeException displayException :: ExitCodeException -> String backtraceDesired :: ExitCodeException -> Bool | |
Show ExitCodeException | |
Defined in System.Process.Typed.Internal Methods showsPrec :: Int -> ExitCodeException -> ShowS show :: ExitCodeException -> String showList :: [ExitCodeException] -> ShowS |
data ByteStringOutputException #
Constructors
ByteStringOutputException SomeException (ProcessConfig () () ()) |
Instances
Exception ByteStringOutputException | |
Defined in System.Process.Typed.Internal Methods toException :: ByteStringOutputException -> SomeException fromException :: SomeException -> Maybe ByteStringOutputException displayException :: ByteStringOutputException -> String backtraceDesired :: ByteStringOutputException -> Bool | |
Show ByteStringOutputException | |
Defined in System.Process.Typed.Internal Methods showsPrec :: Int -> ByteStringOutputException -> ShowS show :: ByteStringOutputException -> String showList :: [ByteStringOutputException] -> ShowS |
byteStringInput :: ByteString -> StreamSpec 'STInput () #
byteStringOutput :: StreamSpec 'STOutput (STM ByteString) #
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a #
mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a #
nullStream :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () #
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 #
setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setCreateNewConsole :: 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 #
setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr #
setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr #
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () #
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () #
withProcess_ :: 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 #
startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr) #
checkExitCodeSTM :: Process stdin stdout stderr -> STM () #
exitCodeExceptionNoOutput :: Process stdin stdout stderr -> ExitCode -> ExitCodeException #
exitCodeExceptionWithOutput :: MonadIO m => Process stdin (STM ByteString) (STM ByteString) -> m ExitCodeException #
getExitCode :: MonadIO m => Process stdin stdout stderr -> m (Maybe ExitCode) #
getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode) #
readProcessInterleaved :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString) #
readProcessInterleaved_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m ByteString #
readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString) #
readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString #
readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString) #
readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString #
readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString) #
runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m () #
stopProcess :: MonadIO m => Process stdin stdout stderr -> m () #
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle #
waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode #
waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode #
withProcessTerm :: 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 #
withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a #