Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.Process.Typed.Dynamic
Description
Provides a dynamic effect for typed process.
Since: 0.1
Synopsis
- data TypedProcess (a :: Type -> Type) b where
- RunProcess :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a ExitCode
- ReadProcess :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString, ByteString)
- ReadProcessStdout :: forall stdin stdoutIgnored stderr (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderr -> TypedProcess a (ExitCode, ByteString)
- ReadProcessStderr :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString)
- ReadProcessInterleaved :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString)
- WithProcessWait :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b
- WithProcessTerm :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b
- StartProcess :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a (Process stdin stdout stderr)
- StopProcess :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a ()
- RunProcess_ :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a ()
- ReadProcess_ :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ByteString, ByteString)
- ReadProcessStdout_ :: forall stdin stdoutIgnored stderr (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderr -> TypedProcess a ByteString
- ReadProcessStderr_ :: forall stdin stdout stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdout stderrIgnored -> TypedProcess a ByteString
- ReadProcessInterleaved_ :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a ByteString
- WithProcessWait_ :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b
- WithProcessTerm_ :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b
- WaitExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a ExitCode
- GetExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a (Maybe ExitCode)
- CheckExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a ()
- runTypedProcess :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (TypedProcess ': es) a -> Eff es a
- data ProcessConfig stdin stdout stderr
- data StreamSpec (streamType :: StreamType) a
- data StreamType
- data Process stdin stdout stderr
- proc :: FilePath -> [String] -> ProcessConfig () () ()
- shell :: String -> ProcessConfig () () ()
- 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
- setEnv :: [(String, String)] -> 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
- 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)
- createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle
- useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()
- 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
- runProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es ExitCode
- readProcess :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString, ByteString)
- readProcessStdout :: forall (es :: [Effect]) stdin stdoutIgnored stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderr -> Eff es (ExitCode, ByteString)
- readProcessStderr :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString)
- readProcessInterleaved :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString)
- withProcessWait :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a
- withProcessTerm :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a
- startProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es (Process stdin stdout stderr)
- stopProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es ()
- runProcess_ :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es ()
- readProcess_ :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ByteString, ByteString)
- readProcessStdout_ :: forall (es :: [Effect]) stdin stdoutIgnored stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderr -> Eff es ByteString
- readProcessStderr_ :: forall (es :: [Effect]) stdin stdout stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderrIgnored -> Eff es ByteString
- readProcessInterleaved_ :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es ByteString
- withProcessWait_ :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a
- withProcessTerm_ :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a
- waitExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es ExitCode
- waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode
- getExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es (Maybe ExitCode)
- getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode)
- checkExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es ()
- checkExitCodeSTM :: Process stdin stdout stderr -> STM ()
- getStdin :: Process stdin stdout stderr -> stdin
- getStdout :: Process stdin stdout stderr -> stdout
- getStderr :: Process stdin stdout stderr -> stderr
- data ExitCodeException = ExitCodeException {
- eceExitCode :: ExitCode
- eceProcessConfig :: ProcessConfig () () ()
- eceStdout :: ByteString
- eceStderr :: ByteString
- data ByteStringOutputException = ByteStringOutputException SomeException (ProcessConfig () () ())
- data ExitCode
- data StdStream
- unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle
Effect
data TypedProcess (a :: Type -> Type) b where Source #
Dynamic effect for typed process.
Since: 0.1
Constructors
RunProcess :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a ExitCode | |
ReadProcess :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString, ByteString) | |
ReadProcessStdout :: forall stdin stdoutIgnored stderr (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderr -> TypedProcess a (ExitCode, ByteString) | |
ReadProcessStderr :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString) | |
ReadProcessInterleaved :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ExitCode, ByteString) | |
WithProcessWait :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b | |
WithProcessTerm :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b | |
StartProcess :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a (Process stdin stdout stderr) | |
StopProcess :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a () | |
RunProcess_ :: forall stdin stdout stderr (a :: Type -> Type). ProcessConfig stdin stdout stderr -> TypedProcess a () | |
ReadProcess_ :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a (ByteString, ByteString) | |
ReadProcessStdout_ :: forall stdin stdoutIgnored stderr (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderr -> TypedProcess a ByteString | |
ReadProcessStderr_ :: forall stdin stdout stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdout stderrIgnored -> TypedProcess a ByteString | |
ReadProcessInterleaved_ :: forall stdin stdoutIgnored stderrIgnored (a :: Type -> Type). ProcessConfig stdin stdoutIgnored stderrIgnored -> TypedProcess a ByteString | |
WithProcessWait_ :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b | |
WithProcessTerm_ :: forall stdin stdout stderr (a :: Type -> Type) b. ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> a b) -> TypedProcess a b | |
WaitExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a ExitCode | |
GetExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a (Maybe ExitCode) | |
CheckExitCode :: forall stdin stdout stderr (a :: Type -> Type). Process stdin stdout stderr -> TypedProcess a () |
Instances
ShowEffect TypedProcess Source # | Since: 0.1 |
Defined in Effectful.Process.Typed.Dynamic Methods showEffectCons :: forall (m :: Type -> Type) a. TypedProcess m a -> String Source # | |
type DispatchOf TypedProcess Source # | Since: 0.1 |
Defined in Effectful.Process.Typed.Dynamic |
Handler
runTypedProcess :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (TypedProcess ': es) a -> Eff es a Source #
Runs TypedProcess
in IO
.
Since: 0.1
Types
data ProcessConfig stdin stdout stderr Source #
An abstract configuration for a process, which can then be
launched into an actual running Process
. Takes three type
parameters, providing the types of standard input, standard output,
and standard error, respectively.
There are three ways to construct a value of this type:
- With the
proc
smart constructor, which takes a command name and a list of arguments. - With the
shell
smart constructor, which takes a shell string - With the
IsString
instance via OverloadedStrings. If you provide it a string with no spaces (e.g.,"date"
), it will treat it as a raw command with no arguments (e.g.,proc "date" []
). If it has spaces, it will useshell
.
In all cases, the default for all three streams is to inherit the streams from the parent process. For other settings, see the setters below for default values.
Once you have a ProcessConfig
you can launch a process from it
using the functions in the section Launch a
process.
Since: typed-process-0.1.0.0
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 # |
data StreamSpec (streamType :: StreamType) a Source #
A specification for how to create one of the three standard child
streams, stdin
, stdout
and stderr
. A StreamSpec
can be
thought of as containing
- A type safe version of
StdStream
from System.Process. This determines whether the stream should be inherited from the parent process, piped to or from aHandle
, etc. - A means of accessing the stream as a value of type
a
- A cleanup action which will be run on the stream once the process terminates
To create a StreamSpec
see the section Stream
specs.
Since: typed-process-0.1.0.0
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) | This instance uses Since: typed-process-0.1.0.0 |
Defined in System.Process.Typed.Internal Methods fromString :: String -> StreamSpec streamType res # |
data StreamType Source #
Whether a stream is an input stream or output stream. Note that
this is from the perspective of the child process, so that a
child's standard input stream is an STInput
, even though the
parent process will be writing to it.
Since: typed-process-0.1.0.0
data Process stdin stdout stderr Source #
A running process. The three type parameters provide the type of the standard input, standard output, and standard error streams.
To interact with a Process
use the functions from the section
Interact with a process.
Since: typed-process-0.1.0.0
ProcessConfig
proc :: FilePath -> [String] -> ProcessConfig () () () Source #
Create a ProcessConfig
from the given command and arguments.
Since: typed-process-0.1.0.0
shell :: String -> ProcessConfig () () () Source #
Create a ProcessConfig
from the given shell command.
Since: typed-process-0.1.0.0
Setters
Arguments
:: StreamSpec 'STInput stdin | |
-> ProcessConfig stdin0 stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set the child's standard input stream to the given StreamSpec
.
Default: inherit
Since: typed-process-0.1.0.0
Arguments
:: StreamSpec 'STOutput stdout | |
-> ProcessConfig stdin stdout0 stderr | |
-> ProcessConfig stdin stdout stderr |
Set the child's standard output stream to the given StreamSpec
.
Default: inherit
Since: typed-process-0.1.0.0
Arguments
:: StreamSpec 'STOutput stderr | |
-> ProcessConfig stdin stdout stderr0 | |
-> ProcessConfig stdin stdout stderr |
Set the child's standard error stream to the given StreamSpec
.
Default: inherit
Since: typed-process-0.1.0.0
Arguments
:: FilePath | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set the working directory of the child process.
Default: current process's working directory.
Since: typed-process-0.1.0.0
Arguments
:: ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Inherit the working directory from the parent process.
Since: typed-process-0.2.2.0
Arguments
:: [(String, String)] | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set the environment variables of the child process.
Default: current process's environment.
Since: typed-process-0.1.0.0
Arguments
:: ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Inherit the environment variables from the parent process.
Since: typed-process-0.2.2.0
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Should we close all file descriptors besides stdin, stdout, and
stderr? See close_fds
for more information.
Default: False
Since: typed-process-0.1.0.0
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Should we create a new process group?
Default: False
Since: typed-process-0.1.0.0
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Delegate handling of Ctrl-C to the child. For more information,
see delegate_ctlc
.
Default: False
Since: typed-process-0.1.0.0
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Arguments
:: Bool | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set a new session with the POSIX setsid
syscall, does nothing
on non-POSIX. See new_session
.
Default: False
Since: typed-process-0.1.0.0
Arguments
:: GroupID | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set the child process's group ID with the POSIX setgid
syscall,
does nothing on non-POSIX. See child_group
.
Default: False
Since: typed-process-0.1.0.0
Arguments
:: ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Inherit the group from the parent process.
Since: typed-process-0.2.2.0
Arguments
:: UserID | |
-> ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Set the child process's user ID with the POSIX setuid
syscall,
does nothing on non-POSIX. See child_user
.
Default: False
Since: typed-process-0.1.0.0
Arguments
:: ProcessConfig stdin stdout stderr | |
-> ProcessConfig stdin stdout stderr |
Inherit the user from the parent process.
Since: typed-process-0.2.2.0
Stream specs
Built-in stream specs
inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () Source #
A stream spec which simply inherits the stream of the parent process.
Since: typed-process-0.1.0.0
nullStream :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () Source #
A stream spec which is empty when used for for input and discards output. Note this requires your platform's null device to be available when the process is started.
Since: typed-process-0.2.5.0
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType () Source #
A stream spec which will close the stream for the child process.
You usually do not want to use this, as it will leave the
corresponding file descriptor unassigned and hence available for
re-use in the child process. Prefer nullStream
unless you're
certain you want this behavior.
Since: typed-process-0.1.0.0
byteStringInput :: ByteString -> StreamSpec 'STInput () Source #
An input stream spec which sets the input to the given
ByteString
. A separate thread will be forked to write the
contents to the child process.
Since: typed-process-0.1.0.0
byteStringOutput :: StreamSpec 'STOutput (STM ByteString) Source #
Capture the output of a process in a ByteString
.
This function will fork a separate thread to consume all input from
the process, and will only make the results available when the
underlying Handle
is closed. As this is provided as an STM
action, you can either check if the result is available, or block
until it's ready.
In the event of any exception occurring when reading from the
Handle
, the STM
action will throw a
ByteStringOutputException
.
Since: typed-process-0.1.0.0
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle Source #
Create a new pipe between this process and the child, and return
a Handle
to communicate with the child.
Since: typed-process-0.1.0.0
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () Source #
Use the provided Handle
for the child process, and when the
process exits, do not close it. This is useful if, for example,
you want to have multiple processes write to the same log file
sequentially.
Since: typed-process-0.1.0.0
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType () Source #
Use the provided Handle
for the child process, and when the
process exits, close it. If you have no reason to keep the Handle
open, you should use this over useHandleOpen
.
Since: typed-process-0.1.0.0
Create your own stream spec
Arguments
:: forall a (streamType :: StreamType). StdStream | |
-> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) | |
-> StreamSpec streamType a |
Create a new StreamSpec
from the given StdStream
and a
helper function. This function:
- Takes as input the raw
Maybe Handle
returned by thecreateProcess
function. The handle will beJust
Handle
if theStdStream
argument isCreatePipe
andNothing
otherwise. SeecreateProcess
for more details. - Returns the actual stream value
a
, as well as a cleanup function to be run when callingstopProcess
.
If making a StreamSpec
with CreatePipe
, prefer mkPipeStreamSpec
,
which encodes the invariant that a Handle
is created.
Since: typed-process-0.1.0.0
Arguments
:: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) | |
-> StreamSpec streamType a |
Create a new CreatePipe
StreamSpec
from the given function.
This function:
- Takes as input the
Handle
returned by thecreateProcess
function. SeecreateProcess
for more details. - Returns the actual stream value
a
, as well as a cleanup function to be run when callingstopProcess
.
Since: typed-process-0.2.10.0
Launch a process
runProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es ExitCode Source #
Lifted runProcess
.
Since: 0.1
readProcess :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString, ByteString) Source #
Lifted readProcess
.
Since: 0.1
readProcessStdout :: forall (es :: [Effect]) stdin stdoutIgnored stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderr -> Eff es (ExitCode, ByteString) Source #
Lifted readProcessStdout
.
Since: 0.1
readProcessStderr :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString) Source #
Lifted readProcessStderr
.
Since: 0.1
readProcessInterleaved :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ExitCode, ByteString) Source #
Lifted readProcessInterleaved
.
Since: 0.1
withProcessWait :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a Source #
Lifted withProcessWait
.
Since: 0.1
withProcessTerm :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a Source #
Lifted withProcessTerm
.
Since: 0.1
startProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es (Process stdin stdout stderr) Source #
Lifted startProcess
.
Since: 0.1
stopProcess :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es () Source #
Lifted stopProcess
.
Since: 0.1
Exception-throwing functions
runProcess_ :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> Eff es () Source #
Lifted runProcess_
.
Since: 0.1
readProcess_ :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es (ByteString, ByteString) Source #
Lifted readProcess_
.
Since: 0.1
readProcessStdout_ :: forall (es :: [Effect]) stdin stdoutIgnored stderr. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderr -> Eff es ByteString Source #
Lifted readProcessStdout_
.
Since: 0.1
readProcessStderr_ :: forall (es :: [Effect]) stdin stdout stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderrIgnored -> Eff es ByteString Source #
Lifted readProcessStderr_
.
Since: 0.1
readProcessInterleaved_ :: forall (es :: [Effect]) stdin stdoutIgnored stderrIgnored. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdoutIgnored stderrIgnored -> Eff es ByteString Source #
Lifted readProcessInterleaved_
.
Since: 0.1
withProcessWait_ :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a Source #
Lifted withProcessWait_
.
Since: 0.1
withProcessTerm_ :: forall (es :: [Effect]) stdin stdout stderr a. (HasCallStack, TypedProcess :> es) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> Eff es a) -> Eff es a Source #
Lifted withProcessTerm_
.
Since: 0.1
Interact with a process
Process exit code
waitExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es ExitCode Source #
Lifted waitExitCode
.
Since: 0.1
waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode Source #
Same as waitExitCode
, but in STM
.
Since: typed-process-0.1.0.0
getExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es (Maybe ExitCode) Source #
Lifted getExitCode
.
Since: 0.1
getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode) Source #
Same as getExitCode
, but in STM
.
Since: typed-process-0.1.0.0
checkExitCode :: forall (es :: [Effect]) stdin stdout stderr. (HasCallStack, TypedProcess :> es) => Process stdin stdout stderr -> Eff es () Source #
Lifted checkExitCode
.
Since: 0.1
checkExitCodeSTM :: Process stdin stdout stderr -> STM () Source #
Same as checkExitCode
, but in STM
.
Since: typed-process-0.1.0.0
Process streams
getStdin :: Process stdin stdout stderr -> stdin Source #
Get the child's standard input stream value.
Since: typed-process-0.1.0.0
getStdout :: Process stdin stdout stderr -> stdout Source #
Get the child's standard output stream value.
Since: typed-process-0.1.0.0
getStderr :: Process stdin stdout stderr -> stderr Source #
Get the child's standard error stream value.
Since: typed-process-0.1.0.0
Exceptions
data ExitCodeException Source #
Exception thrown by checkExitCode
in the event of a
non-success exit code. Note that checkExitCode
is
called by other functions as well, like runProcess_
or readProcess_
.
Note that several functions that throw an ExitCodeException
intentionally do not populate eceStdout
or eceStderr
.
This prevents unbounded memory usage for large stdout and stderrs.
Functions which do include eceStdout
or eceStderr
(like
readProcess_
) state so in their documentation.
Since: typed-process-0.1.0.0
Constructors
ExitCodeException | |
Fields
|
Instances
Exception ExitCodeException | |
Defined in System.Process.Typed.Internal Methods toException :: ExitCodeException -> SomeException # fromException :: SomeException -> Maybe ExitCodeException # | |
Show ExitCodeException | |
Defined in System.Process.Typed.Internal Methods showsPrec :: Int -> ExitCodeException -> ShowS # show :: ExitCodeException -> String # showList :: [ExitCodeException] -> ShowS # |
data ByteStringOutputException Source #
Wrapper for when an exception is thrown when reading from a child
process, used by byteStringOutput
.
Since: typed-process-0.1.0.0
Constructors
ByteStringOutputException SomeException (ProcessConfig () () ()) |
Instances
Exception ByteStringOutputException | |
Show ByteStringOutputException | |
Defined in System.Process.Typed.Internal Methods showsPrec :: Int -> ByteStringOutputException -> ShowS # show :: ByteStringOutputException -> String # showList :: [ByteStringOutputException] -> ShowS # |
Re-exports
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
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 |
Instances
Unsafe functions
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle Source #
Take ProcessHandle
out of the Process
.
This method is needed in cases one need to use low level functions
from the process
package. Use cases for this method are:
- Send a special signal to the process.
- Terminate the process group instead of terminating single process.
- Use platform specific API on the underlying process.
This method is considered unsafe because the actions it performs on
the underlying process may overlap with the functionality that
typed-process
provides. For example the user should not call
waitForProcess
on the process handle as either
waitForProcess
or stopProcess
will lock.
Additionally, even if process was terminated by the
terminateProcess
or by sending signal,
stopProcess
should be called either way in order to cleanup resources
allocated by the typed-process
.
Since: typed-process-0.1.1