HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletyped-process-0.2.13.0Haskell2010

System.Process.Typed.Internal

This module is internal and its contents may change without a warning or announcement. It is not subject to the PVP.

  • 6 types
  • 37 values
datadata ProcessConfig stdin stdout stderr
#

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 use shell.

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.

Instances2Show, IsString
  • Show (ProcessConfig stdin stdout stderr)Defined in typed-process-0.2.13.0 · System.Process.Typed.Internal
  • (stdin ~ (), stdout ~ (), stderr ~ ()) => IsString (ProcessConfig stdin stdout stderr)Defined in typed-process-0.2.13.0 · System.Process.Typed.Internal
datadata StreamType
#

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.

datadata StreamSpec (streamType :: StreamType) a
#

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

  1. 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 a Handle, etc.

  2. A means of accessing the stream as a value of type a

  3. A cleanup action which will be run on the stream once the process terminates

To create a StreamSpec see the section Stream specs.

Constructors

Instances2Functor, IsString
  • Functor (StreamSpec streamType)Defined in typed-process-0.2.13.0 · System.Process.Typed.Internal
  • (streamType ~ 'STInput, res ~ ()) => IsString (StreamSpec streamType res)Defined in typed-process-0.2.13.0 · System.Process.Typed.Internal

    This instance uses byteStringInput to convert a raw string into a stream of input for a child process.

newtypenewtype Cleanup a
#

Internal type, to make for easier composition of cleanup actions.

Constructors

Instances2Functor, Applicative
  • Functor CleanupDefined in typed-process-0.2.13.0 · System.Process.Typed.Internal
  • Applicative CleanupDefined in typed-process-0.2.13.0 · System.Process.Typed.Internal
valuemkStreamSpec
  1. :: StdStream
  2. -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ()))
  3. -> 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 the createProcess function. The handle will be Just Handle if the StdStream argument is CreatePipe and Nothing otherwise. See createProcess for more details.

  • Returns the actual stream value a, as well as a cleanup function to be run when calling stopProcess.

If making a StreamSpec with CreatePipe, prefer mkPipeStreamSpec, which encodes the invariant that a Handle is created.

valueinherit :: StreamSpec anyStreamType ()
#

A stream spec which simply inherits the stream of the parent process.

valuenullStream :: StreamSpec anyStreamType ()
#

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.

valueclosed :: StreamSpec anyStreamType ()
#

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.

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.

valueuseHandleOpen :: Handle -> StreamSpec anyStreamType ()
#

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.

datadata ExitCodeException
#

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.

Instances2Show, Exception