-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Run external processes, with strong typing of streams
--   
--   Please see the tutorial at
--   <a>https://github.com/fpco/typed-process#readme</a>
@package typed-process
@version 0.2.12.0


-- | This module is <b>internal</b> and its contents may change without a
--   warning or announcement. It is not subject to the PVP.
module System.Process.Typed.Internal

-- | An abstract configuration for a process, which can then be launched
--   into an actual running <tt>Process</tt>. 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:
--   
--   <ul>
--   <li>With the <a>proc</a> smart constructor, which takes a command name
--   and a list of arguments.</li>
--   <li>With the <a>shell</a> smart constructor, which takes a shell
--   string</li>
--   <li>With the <a>IsString</a> instance via OverloadedStrings. If you
--   provide it a string with no spaces (e.g., <tt>"date"</tt>), it will
--   treat it as a raw command with no arguments (e.g., <tt>proc "date"
--   []</tt>). If it has spaces, it will use <tt>shell</tt>.</li>
--   </ul>
--   
--   In all cases, the default for all three streams is to inherit the
--   streams from the parent process. For other settings, see the
--   <a>setters below</a> for default values.
--   
--   Once you have a <tt>ProcessConfig</tt> you can launch a process from
--   it using the functions in the section <a>Launch a process</a>.
data ProcessConfig stdin stdout stderr
ProcessConfig :: !CmdSpec -> !StreamSpec 'STInput stdin -> !StreamSpec 'STOutput stdout -> !StreamSpec 'STOutput stderr -> !Maybe FilePath -> !Maybe [(String, String)] -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Maybe GroupID -> !Maybe UserID -> ProcessConfig stdin stdout stderr
[pcCmdSpec] :: ProcessConfig stdin stdout stderr -> !CmdSpec
[pcStdin] :: ProcessConfig stdin stdout stderr -> !StreamSpec 'STInput stdin
[pcStdout] :: ProcessConfig stdin stdout stderr -> !StreamSpec 'STOutput stdout
[pcStderr] :: ProcessConfig stdin stdout stderr -> !StreamSpec 'STOutput stderr
[pcWorkingDir] :: ProcessConfig stdin stdout stderr -> !Maybe FilePath
[pcEnv] :: ProcessConfig stdin stdout stderr -> !Maybe [(String, String)]
[pcCloseFds] :: ProcessConfig stdin stdout stderr -> !Bool
[pcCreateGroup] :: ProcessConfig stdin stdout stderr -> !Bool
[pcDelegateCtlc] :: ProcessConfig stdin stdout stderr -> !Bool
[pcDetachConsole] :: ProcessConfig stdin stdout stderr -> !Bool
[pcCreateNewConsole] :: ProcessConfig stdin stdout stderr -> !Bool
[pcNewSession] :: ProcessConfig stdin stdout stderr -> !Bool
[pcChildGroup] :: ProcessConfig stdin stdout stderr -> !Maybe GroupID
[pcChildUser] :: ProcessConfig stdin stdout stderr -> !Maybe UserID

-- | Whether a stream is an input stream or output stream. Note that this
--   is from the perspective of the <i>child process</i>, so that a child's
--   standard input stream is an <tt>STInput</tt>, even though the parent
--   process will be writing to it.
data StreamType
STInput :: StreamType
STOutput :: StreamType

-- | A specification for how to create one of the three standard child
--   streams, <tt>stdin</tt>, <tt>stdout</tt> and <tt>stderr</tt>. A
--   <a>StreamSpec</a> can be thought of as containing
--   
--   <ol>
--   <li>A type safe version of <a>StdStream</a> from
--   <a>System.Process</a>. This determines whether the stream should be
--   inherited from the parent process, piped to or from a <a>Handle</a>,
--   etc.</li>
--   <li>A means of accessing the stream as a value of type <tt>a</tt></li>
--   <li>A cleanup action which will be run on the stream once the process
--   terminates</li>
--   </ol>
--   
--   To create a <tt>StreamSpec</tt> see the section <a>Stream specs</a>.
data StreamSpec (streamType :: StreamType) a
StreamSpec :: !forall b. (StdStream -> IO b) -> IO b -> !ProcessConfig () () () -> Maybe Handle -> Cleanup a -> StreamSpec (streamType :: StreamType) a
[ssStream] :: StreamSpec (streamType :: StreamType) a -> !forall b. (StdStream -> IO b) -> IO b
[ssCreate] :: StreamSpec (streamType :: StreamType) a -> !ProcessConfig () () () -> Maybe Handle -> Cleanup a

-- | Internal type, to make for easier composition of cleanup actions.
newtype Cleanup a
Cleanup :: IO (a, IO ()) -> Cleanup a
[runCleanup] :: Cleanup a -> IO (a, IO ())

-- | Internal helper
defaultProcessConfig :: ProcessConfig () () ()

-- | Create a <a>ProcessConfig</a> from the given command and arguments.
proc :: FilePath -> [String] -> ProcessConfig () () ()

-- | Internal helper
setProc :: FilePath -> [String] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create a <a>ProcessConfig</a> from the given shell command.
shell :: String -> ProcessConfig () () ()

-- | Internal helper
setShell :: String -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard input stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard output stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard error stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr

-- | Set the working directory of the child process.
--   
--   Default: current process's working directory.
setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the working directory from the parent process.
setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the environment variables of the child process.
--   
--   Default: current process's environment.
setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the environment variables from the parent process.
setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Should we close all file descriptors besides stdin, stdout, and
--   stderr? See <a>close_fds</a> for more information.
--   
--   Default: False
setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Should we create a new process group?
--   
--   Default: False
setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Delegate handling of Ctrl-C to the child. For more information, see
--   <a>delegate_ctlc</a>.
--   
--   Default: False
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Detach console on Windows, see <a>detach_console</a>.
--   
--   Default: False
setDetachConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create new console on Windows, see <a>create_new_console</a>.
--   
--   Default: False
setCreateNewConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set a new session with the POSIX <tt>setsid</tt> syscall, does nothing
--   on non-POSIX. See <a>new_session</a>.
--   
--   Default: False
setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's group ID with the POSIX <tt>setgid</tt>
--   syscall, does nothing on non-POSIX. See <a>child_group</a>.
--   
--   Default: False
setChildGroup :: GroupID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the group from the parent process.
setChildGroupInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's user ID with the POSIX <tt>setuid</tt>
--   syscall, does nothing on non-POSIX. See <a>child_user</a>.
--   
--   Default: False
setChildUser :: UserID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the user from the parent process.
setChildUserInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create a new <a>StreamSpec</a> from the given <a>StdStream</a> and a
--   helper function. This function:
--   
--   <ul>
--   <li>Takes as input the raw <tt>Maybe Handle</tt> returned by the
--   <a>createProcess</a> function. The handle will be <tt>Just</tt>
--   <a>Handle</a> if the <a>StdStream</a> argument is <a>CreatePipe</a>
--   and <tt>Nothing</tt> otherwise. See <a>createProcess</a> for more
--   details.</li>
--   <li>Returns the actual stream value <tt>a</tt>, as well as a cleanup
--   function to be run when calling <tt>stopProcess</tt>.</li>
--   </ul>
--   
--   If making a <a>StreamSpec</a> with <a>CreatePipe</a>, prefer
--   <a>mkPipeStreamSpec</a>, which encodes the invariant that a
--   <a>Handle</a> is created.
mkStreamSpec :: StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | Create a new <a>CreatePipe</a> <a>StreamSpec</a> from the given
--   function. This function:
--   
--   <ul>
--   <li>Takes as input the <tt>Handle</tt> returned by the
--   <a>createProcess</a> function. See <a>createProcess</a> for more
--   details.</li>
--   <li>Returns the actual stream value <tt>a</tt>, as well as a cleanup
--   function to be run when calling <tt>stopProcess</tt>.</li>
--   </ul>
mkPipeStreamSpec :: (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | Create a new <a>StreamSpec</a> from a function that accepts a
--   <a>StdStream</a> and a helper function. This function is the same as
--   the helper in <a>mkStreamSpec</a>
mkManagedStreamSpec :: (forall b. (StdStream -> IO b) -> IO b) -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | A stream spec which simply inherits the stream of the parent process.
inherit :: 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.
nullStream :: 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 <a>nullStream</a> unless you're certain you want this
--   behavior.
closed :: StreamSpec anyStreamType ()

-- | An input stream spec which sets the input to the given
--   <a>ByteString</a>. A separate thread will be forked to write the
--   contents to the child process.
byteStringInput :: ByteString -> StreamSpec 'STInput ()

-- | Capture the output of a process in a <a>ByteString</a>.
--   
--   This function will fork a separate thread to consume all input from
--   the process, and will only make the results available when the
--   underlying <a>Handle</a> is closed. As this is provided as an
--   <a>STM</a> 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
--   <a>Handle</a>, the <a>STM</a> action will throw a
--   <a>ByteStringOutputException</a>.
byteStringOutput :: StreamSpec 'STOutput (STM ByteString)

-- | Helper function (not exposed) for both <a>byteStringOutput</a> and
--   <tt>withProcessInterleave</tt>. This will consume all of the output
--   from the given <a>Handle</a> in a separate thread and provide access
--   to the resulting <a>ByteString</a> via STM. Second action will close
--   the reader handle.
byteStringFromHandle :: ProcessConfig () () () -> Handle -> IO (STM ByteString, IO ())

-- | Create a new pipe between this process and the child, and return a
--   <a>Handle</a> to communicate with the child.
createPipe :: StreamSpec anyStreamType Handle

-- | Use the provided <a>Handle</a> for the child process, and when the
--   process exits, do <i>not</i> close it. This is useful if, for example,
--   you want to have multiple processes write to the same log file
--   sequentially.
useHandleOpen :: Handle -> StreamSpec anyStreamType ()

-- | Use the provided <a>Handle</a> for the child process, and when the
--   process exits, close it. If you have no reason to keep the
--   <a>Handle</a> open, you should use this over <a>useHandleOpen</a>.
useHandleClose :: Handle -> StreamSpec anyStreamType ()

-- | Exception thrown by <a>checkExitCode</a> in the event of a non-success
--   exit code. Note that <a>checkExitCode</a> is called by other functions
--   as well, like <a>runProcess_</a> or <a>readProcess_</a>.
--   
--   Note that several functions that throw an <a>ExitCodeException</a>
--   intentionally do not populate <a>eceStdout</a> or <a>eceStderr</a>.
--   This prevents unbounded memory usage for large stdout and stderrs.
--   
--   Functions which do include <a>eceStdout</a> or <a>eceStderr</a> (like
--   <a>readProcess_</a>) state so in their documentation.
data ExitCodeException
ExitCodeException :: ExitCode -> ProcessConfig () () () -> ByteString -> ByteString -> ExitCodeException
[eceExitCode] :: ExitCodeException -> ExitCode
[eceProcessConfig] :: ExitCodeException -> ProcessConfig () () ()
[eceStdout] :: ExitCodeException -> ByteString
[eceStderr] :: ExitCodeException -> ByteString

-- | Wrapper for when an exception is thrown when reading from a child
--   process, used by <a>byteStringOutput</a>.
data ByteStringOutputException
ByteStringOutputException :: SomeException -> ProcessConfig () () () -> ByteStringOutputException
bracket :: MonadUnliftIO m => IO a -> (a -> IO b) -> (a -> m c) -> m c
finally :: MonadUnliftIO m => m a -> IO () -> m a

-- | The name of the system null device
nullDevice :: FilePath
instance GHC.Base.Functor System.Process.Typed.Internal.Cleanup
instance GHC.Base.Functor (System.Process.Typed.Internal.StreamSpec streamType)
instance GHC.Show.Show System.Process.Typed.Internal.ByteStringOutputException
instance GHC.Exception.Type.Exception System.Process.Typed.Internal.ByteStringOutputException
instance GHC.Exception.Type.Exception System.Process.Typed.Internal.ExitCodeException
instance GHC.Show.Show System.Process.Typed.Internal.ExitCodeException
instance GHC.Show.Show (System.Process.Typed.Internal.ProcessConfig stdin stdout stderr)
instance (stdin GHC.Types.~ (), stdout GHC.Types.~ (), stderr GHC.Types.~ ()) => Data.String.IsString (System.Process.Typed.Internal.ProcessConfig stdin stdout stderr)
instance (streamType GHC.Types.~ 'System.Process.Typed.Internal.STInput, res GHC.Types.~ ()) => Data.String.IsString (System.Process.Typed.Internal.StreamSpec streamType res)
instance GHC.Base.Applicative System.Process.Typed.Internal.Cleanup


-- | The simplest way to get started with this API is to turn on
--   <tt>OverloadedStrings</tt> and call <a>runProcess</a>. The following
--   will write the contents of <tt>/home</tt> to <tt>stdout</tt> and then
--   print the exit code (on a UNIX system).
--   
--   <pre>
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   <a>runProcess</a> "ls -l /home" &gt;&gt;= print
--   </pre>
--   
--   Please see the <a>README.md</a> file for more examples of using this
--   API.
module System.Process.Typed

-- | An abstract configuration for a process, which can then be launched
--   into an actual running <tt>Process</tt>. 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:
--   
--   <ul>
--   <li>With the <a>proc</a> smart constructor, which takes a command name
--   and a list of arguments.</li>
--   <li>With the <a>shell</a> smart constructor, which takes a shell
--   string</li>
--   <li>With the <a>IsString</a> instance via OverloadedStrings. If you
--   provide it a string with no spaces (e.g., <tt>"date"</tt>), it will
--   treat it as a raw command with no arguments (e.g., <tt>proc "date"
--   []</tt>). If it has spaces, it will use <tt>shell</tt>.</li>
--   </ul>
--   
--   In all cases, the default for all three streams is to inherit the
--   streams from the parent process. For other settings, see the
--   <a>setters below</a> for default values.
--   
--   Once you have a <tt>ProcessConfig</tt> you can launch a process from
--   it using the functions in the section <a>Launch a process</a>.
data ProcessConfig stdin stdout stderr

-- | A specification for how to create one of the three standard child
--   streams, <tt>stdin</tt>, <tt>stdout</tt> and <tt>stderr</tt>. A
--   <a>StreamSpec</a> can be thought of as containing
--   
--   <ol>
--   <li>A type safe version of <a>StdStream</a> from
--   <a>System.Process</a>. This determines whether the stream should be
--   inherited from the parent process, piped to or from a <a>Handle</a>,
--   etc.</li>
--   <li>A means of accessing the stream as a value of type <tt>a</tt></li>
--   <li>A cleanup action which will be run on the stream once the process
--   terminates</li>
--   </ol>
--   
--   To create a <tt>StreamSpec</tt> see the section <a>Stream specs</a>.
data StreamSpec (streamType :: StreamType) a

-- | Whether a stream is an input stream or output stream. Note that this
--   is from the perspective of the <i>child process</i>, so that a child's
--   standard input stream is an <tt>STInput</tt>, even though the parent
--   process will be writing to it.
data StreamType
STInput :: StreamType
STOutput :: StreamType

-- | A running process. The three type parameters provide the type of the
--   standard input, standard output, and standard error streams.
--   
--   To interact with a <tt>Process</tt> use the functions from the section
--   <a>Interact with a process</a>.
data Process stdin stdout stderr

-- | Create a <a>ProcessConfig</a> from the given command and arguments.
proc :: FilePath -> [String] -> ProcessConfig () () ()

-- | Create a <a>ProcessConfig</a> from the given shell command.
shell :: String -> ProcessConfig () () ()

-- | Set the child's standard input stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard output stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard error stream to the given <a>StreamSpec</a>.
--   
--   Default: <a>inherit</a>
setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr

-- | Set the working directory of the child process.
--   
--   Default: current process's working directory.
setWorkingDir :: FilePath -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the working directory from the parent process.
setWorkingDirInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the environment variables of the child process.
--   
--   Default: current process's environment.
setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the environment variables from the parent process.
setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Should we close all file descriptors besides stdin, stdout, and
--   stderr? See <a>close_fds</a> for more information.
--   
--   Default: False
setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Should we create a new process group?
--   
--   Default: False
setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Delegate handling of Ctrl-C to the child. For more information, see
--   <a>delegate_ctlc</a>.
--   
--   Default: False
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Detach console on Windows, see <a>detach_console</a>.
--   
--   Default: False
setDetachConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create new console on Windows, see <a>create_new_console</a>.
--   
--   Default: False
setCreateNewConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set a new session with the POSIX <tt>setsid</tt> syscall, does nothing
--   on non-POSIX. See <a>new_session</a>.
--   
--   Default: False
setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's group ID with the POSIX <tt>setgid</tt>
--   syscall, does nothing on non-POSIX. See <a>child_group</a>.
--   
--   Default: False
setChildGroup :: GroupID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the group from the parent process.
setChildGroupInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's user ID with the POSIX <tt>setuid</tt>
--   syscall, does nothing on non-POSIX. See <a>child_user</a>.
--   
--   Default: False
setChildUser :: UserID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Inherit the user from the parent process.
setChildUserInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | A stream spec which simply inherits the stream of the parent process.
inherit :: 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.
nullStream :: 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 <a>nullStream</a> unless you're certain you want this
--   behavior.
closed :: StreamSpec anyStreamType ()

-- | An input stream spec which sets the input to the given
--   <a>ByteString</a>. A separate thread will be forked to write the
--   contents to the child process.
byteStringInput :: ByteString -> StreamSpec 'STInput ()

-- | Capture the output of a process in a <a>ByteString</a>.
--   
--   This function will fork a separate thread to consume all input from
--   the process, and will only make the results available when the
--   underlying <a>Handle</a> is closed. As this is provided as an
--   <a>STM</a> 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
--   <a>Handle</a>, the <a>STM</a> action will throw a
--   <a>ByteStringOutputException</a>.
byteStringOutput :: StreamSpec 'STOutput (STM ByteString)

-- | Create a new pipe between this process and the child, and return a
--   <a>Handle</a> to communicate with the child.
createPipe :: StreamSpec anyStreamType Handle

-- | Use the provided <a>Handle</a> for the child process, and when the
--   process exits, do <i>not</i> close it. This is useful if, for example,
--   you want to have multiple processes write to the same log file
--   sequentially.
useHandleOpen :: Handle -> StreamSpec anyStreamType ()

-- | Use the provided <a>Handle</a> for the child process, and when the
--   process exits, close it. If you have no reason to keep the
--   <a>Handle</a> open, you should use this over <a>useHandleOpen</a>.
useHandleClose :: Handle -> StreamSpec anyStreamType ()

-- | Create a new <a>StreamSpec</a> from the given <a>StdStream</a> and a
--   helper function. This function:
--   
--   <ul>
--   <li>Takes as input the raw <tt>Maybe Handle</tt> returned by the
--   <a>createProcess</a> function. The handle will be <tt>Just</tt>
--   <a>Handle</a> if the <a>StdStream</a> argument is <a>CreatePipe</a>
--   and <tt>Nothing</tt> otherwise. See <a>createProcess</a> for more
--   details.</li>
--   <li>Returns the actual stream value <tt>a</tt>, as well as a cleanup
--   function to be run when calling <tt>stopProcess</tt>.</li>
--   </ul>
--   
--   If making a <a>StreamSpec</a> with <a>CreatePipe</a>, prefer
--   <a>mkPipeStreamSpec</a>, which encodes the invariant that a
--   <a>Handle</a> is created.
mkStreamSpec :: StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | Create a new <a>CreatePipe</a> <a>StreamSpec</a> from the given
--   function. This function:
--   
--   <ul>
--   <li>Takes as input the <tt>Handle</tt> returned by the
--   <a>createProcess</a> function. See <a>createProcess</a> for more
--   details.</li>
--   <li>Returns the actual stream value <tt>a</tt>, as well as a cleanup
--   function to be run when calling <tt>stopProcess</tt>.</li>
--   </ul>
mkPipeStreamSpec :: (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | Run the given process, wait for it to exit, and returns its
--   <a>ExitCode</a>.
runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode

-- | Run a process, capture its standard output and error as a
--   <a>ByteString</a>, wait for it to complete, and then return its exit
--   code, output, and error.
--   
--   Note that any previously used <a>setStdout</a> or <a>setStderr</a>
--   will be overridden.
readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString)

-- | Same as <a>readProcess</a>, but only read the stdout of the process.
--   Original settings for stderr remain.
readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString)

-- | Same as <a>readProcess</a>, but only read the stderr of the process.
--   Original settings for stdout remain.
readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString)

-- | Same as <a>readProcess</a>, but interleaves stderr with stdout.
--   
--   Motivation: Use this function if you need stdout interleaved with
--   stderr output (e.g. from an HTTP server) in order to debug failures.
readProcessInterleaved :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString)

-- | Uses the bracket pattern to call <a>startProcess</a>. Unlike
--   <a>withProcessTerm</a>, this function will wait for the child process
--   to exit, and only kill it with <a>stopProcess</a> in the event that
--   the inner function throws an exception.
--   
--   To interact with a <tt>Process</tt> use the functions from the section
--   <a>Interact with a process</a>.
withProcessWait :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Uses the bracket pattern to call <a>startProcess</a> and ensures that
--   <a>stopProcess</a> is called.
--   
--   This function is usually <i>not</i> what you want. You're likely
--   better off using <a>withProcessWait</a>. See
--   <a>https://github.com/fpco/typed-process/issues/25</a>.
withProcessTerm :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Launch a process based on the given <a>ProcessConfig</a>. You should
--   ensure that you call <a>stopProcess</a> on the result. It's usually
--   better to use one of the functions in this module which ensures
--   <a>stopProcess</a> is called, such as <a>withProcessWait</a>.
startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr)

-- | Close a process and release any resources acquired. This will ensure
--   <a>terminateProcess</a> is called, wait for the process to actually
--   exit, and then close out resources allocated for the streams. In the
--   event of any cleanup exceptions being thrown this will throw an
--   exception.
stopProcess :: MonadIO m => Process stdin stdout stderr -> m ()

-- | Same as <a>runProcess</a>, but instead of returning the
--   <a>ExitCode</a>, checks it with <a>checkExitCode</a>.
runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m ()

-- | Same as <a>readProcess</a>, but instead of returning the
--   <a>ExitCode</a>, checks it with <a>checkExitCode</a>.
--   
--   Exceptions thrown by this function will include stdout and stderr.
readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString)

-- | Same as <a>readProcessStdout</a>, but instead of returning the
--   <a>ExitCode</a>, checks it with <a>checkExitCode</a>.
--   
--   Exceptions thrown by this function will include stdout.
readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString

-- | Same as <a>readProcessStderr</a>, but instead of returning the
--   <a>ExitCode</a>, checks it with <a>checkExitCode</a>.
--   
--   Exceptions thrown by this function will include stderr.
readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString

-- | Same as <a>readProcessInterleaved</a>, but instead of returning the
--   <a>ExitCode</a>, checks it with <a>checkExitCode</a>.
--   
--   Exceptions thrown by this function will include stdout.
readProcessInterleaved_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m ByteString

-- | Same as <a>withProcessWait</a>, but also calls <a>checkExitCode</a>
withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as <a>withProcessTerm</a>, but also calls <a>checkExitCode</a>
--   
--   To interact with a <tt>Process</tt> use the functions from the section
--   <a>Interact with a process</a>.
withProcessTerm_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Wait for the process to exit and then return its <a>ExitCode</a>.
waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode

-- | Same as <a>waitExitCode</a>, but in <a>STM</a>.
waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode

-- | Check if a process has exited and, if so, return its <a>ExitCode</a>.
getExitCode :: MonadIO m => Process stdin stdout stderr -> m (Maybe ExitCode)

-- | Same as <a>getExitCode</a>, but in <a>STM</a>.
getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode)

-- | Wait for a process to exit, and ensure that it exited successfully. If
--   not, throws an <a>ExitCodeException</a>.
--   
--   Exceptions thrown by this function will not include stdout or stderr
--   (This prevents unbounded memory usage from reading them into memory).
--   However, some callers such as <a>readProcess_</a> catch the exception,
--   add the stdout and stderr, and rethrow.
checkExitCode :: MonadIO m => Process stdin stdout stderr -> m ()

-- | Same as <a>checkExitCode</a>, but in <a>STM</a>.
checkExitCodeSTM :: Process stdin stdout stderr -> STM ()

-- | Returns the PID (process ID) of a subprocess.
--   
--   <a>Nothing</a> is returned if the underlying <a>ProcessHandle</a> was
--   already closed. Otherwise a PID is returned that remains valid as long
--   as the handle is open. The operating system may reuse the PID as soon
--   as the last handle to the process is closed.
getPid :: Process stdin stdout stderr -> IO (Maybe Pid)

-- | Get the child's standard input stream value.
getStdin :: Process stdin stdout stderr -> stdin

-- | Get the child's standard output stream value.
getStdout :: Process stdin stdout stderr -> stdout

-- | Get the child's standard error stream value.
getStderr :: Process stdin stdout stderr -> stderr

-- | Exception thrown by <a>checkExitCode</a> in the event of a non-success
--   exit code. Note that <a>checkExitCode</a> is called by other functions
--   as well, like <a>runProcess_</a> or <a>readProcess_</a>.
--   
--   Note that several functions that throw an <a>ExitCodeException</a>
--   intentionally do not populate <a>eceStdout</a> or <a>eceStderr</a>.
--   This prevents unbounded memory usage for large stdout and stderrs.
--   
--   Functions which do include <a>eceStdout</a> or <a>eceStderr</a> (like
--   <a>readProcess_</a>) state so in their documentation.
data ExitCodeException
ExitCodeException :: ExitCode -> ProcessConfig () () () -> ByteString -> ByteString -> ExitCodeException
[eceExitCode] :: ExitCodeException -> ExitCode
[eceProcessConfig] :: ExitCodeException -> ProcessConfig () () ()
[eceStdout] :: ExitCodeException -> ByteString
[eceStderr] :: ExitCodeException -> ByteString

-- | Get an <a>ExitCodeException</a> containing the process's stdout and
--   stderr data.
--   
--   Note that this will call <a>waitExitCode</a> to block until the
--   process exits, if it has not exited already.
--   
--   Unlike <a>checkExitCode</a> and similar, this will return an
--   <a>ExitCodeException</a> even if the process exits with
--   <a>ExitSuccess</a>.
exitCodeExceptionWithOutput :: MonadIO m => Process stdin (STM ByteString) (STM ByteString) -> m ExitCodeException

-- | Get an <a>ExitCodeException</a> containing no data other than the exit
--   code and process config.
--   
--   Unlike <a>checkExitCode</a> and similar, this will return an
--   <a>ExitCodeException</a> even if the process exits with
--   <a>ExitSuccess</a>.
exitCodeExceptionNoOutput :: Process stdin stdout stderr -> ExitCode -> ExitCodeException

-- | Wrapper for when an exception is thrown when reading from a child
--   process, used by <a>byteStringOutput</a>.
data ByteStringOutputException
ByteStringOutputException :: SomeException -> ProcessConfig () () () -> ByteStringOutputException

-- | Defines the exit codes that a program can return.
data () => ExitCode

-- | indicates successful termination;
ExitSuccess :: ExitCode

-- | 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).
ExitFailure :: Int -> ExitCode
data () => StdStream

-- | Inherit Handle from parent
Inherit :: StdStream

-- | Use the supplied Handle
UseHandle :: Handle -> StdStream

-- | Create a new pipe. The returned <tt>Handle</tt> will use the default
--   encoding and newline translation mode (just like <tt>Handle</tt>s
--   created by <tt>openFile</tt>).
CreatePipe :: StdStream

-- | 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
--   <tt>Handle</tt> that writes to <tt>/dev/null</tt>.
NoStream :: StdStream

-- | The platform specific type for a process identifier.
--   
--   This is always an integral type. Width and signedness are platform
--   specific.
type Pid = CPid

-- | Take <a>ProcessHandle</a> out of the <a>Process</a>. This method is
--   needed in cases one need to use low level functions from the
--   <tt>process</tt> package. Use cases for this method are:
--   
--   <ol>
--   <li>Send a special signal to the process.</li>
--   <li>Terminate the process group instead of terminating single
--   process.</li>
--   <li>Use platform specific API on the underlying process.</li>
--   </ol>
--   
--   This method is considered unsafe because the actions it performs on
--   the underlying process may overlap with the functionality that
--   <tt>typed-process</tt> provides. For example the user should not call
--   <a>waitForProcess</a> on the process handle as either
--   <a>waitForProcess</a> or <a>stopProcess</a> will lock. Additionally,
--   even if process was terminated by the <a>terminateProcess</a> or by
--   sending signal, <a>stopProcess</a> should be called either way in
--   order to cleanup resources allocated by the <tt>typed-process</tt>.
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle

-- | Deprecated synonym for <a>withProcessTerm</a>.

-- | <i>Deprecated: Please consider using <a>withProcessWait</a>, or
--   instead use <a>withProcessTerm</a></i>
withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Deprecated synonym for <a>withProcessTerm_</a>.

-- | <i>Deprecated: Please consider using <a>withProcessWait_</a>, or
--   instead use <a>withProcessTerm_</a></i>
withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
instance GHC.Show.Show (System.Process.Typed.Process stdin stdout stderr)
