-- 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
--   https://github.com/fpco/typed-process#readme
@package typed-process
@version 0.2.13.0

-- | This module is internal 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 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.
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 child process, so that a child's
--   standard input stream is an STInput, 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, 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 a Handle,
--   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.
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 ProcessConfig 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 ProcessConfig 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 StreamSpec.
--   
--   Default: inherit
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr

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

-- | Set the child's standard error stream to the given StreamSpec.
--   
--   Default: inherit
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 close_fds 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
--   delegate_ctlc.
--   
--   Default: False
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

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

-- | Create new console on Windows, see create_new_console.
--   
--   Default: False
setCreateNewConsole :: 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
setNewSession :: Bool -> 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
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 setuid
--   syscall, does nothing on non-POSIX. See child_user.
--   
--   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 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.
mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe 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 the
--   createProcess function. See createProcess for more
--   details.
--   
- Returns the actual stream value a, as well as a cleanup
--   function to be run when calling stopProcess.
--   
mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | Create a new StreamSpec from a function that accepts a
--   StdStream and a helper function. This function is the same as
--   the helper in mkStreamSpec
mkManagedStreamSpec :: forall a (streamType :: StreamType). (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 :: forall (anyStreamType :: StreamType). 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 :: forall (anyStreamType :: StreamType). 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.
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()

-- | 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.
byteStringInput :: ByteString -> StreamSpec 'STInput ()

-- | 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.
byteStringOutput :: StreamSpec 'STOutput (STM ByteString)

-- | Helper function (not exposed) for both byteStringOutput and
--   withProcessInterleave. This will consume all of the output
--   from the given Handle in a separate thread and provide access
--   to the resulting ByteString 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
--   Handle to communicate with the child.
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle

-- | 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.
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | 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.
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | 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.
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 byteStringOutput.
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.Internal.Base.Applicative System.Process.Typed.Internal.Cleanup
instance GHC.Internal.Exception.Type.Exception System.Process.Typed.Internal.ByteStringOutputException
instance GHC.Internal.Exception.Type.Exception System.Process.Typed.Internal.ExitCodeException
instance GHC.Internal.Base.Functor System.Process.Typed.Internal.Cleanup
instance GHC.Internal.Base.Functor (System.Process.Typed.Internal.StreamSpec streamType)
instance (stdin GHC.Types.~ (), stdout GHC.Types.~ (), stderr GHC.Types.~ ()) => GHC.Internal.Data.String.IsString (System.Process.Typed.Internal.ProcessConfig stdin stdout stderr)
instance (streamType GHC.Types.~ 'System.Process.Typed.Internal.STInput, res GHC.Types.~ ()) => GHC.Internal.Data.String.IsString (System.Process.Typed.Internal.StreamSpec streamType res)
instance GHC.Internal.Show.Show System.Process.Typed.Internal.ByteStringOutputException
instance GHC.Internal.Show.Show System.Process.Typed.Internal.ExitCodeException
instance GHC.Internal.Show.Show (System.Process.Typed.Internal.ProcessConfig stdin stdout stderr)

-- | The simplest way to get started with this API is to turn on
--   OverloadedStrings and call runProcess. The following
--   will write the contents of /home to stdout and then
--   print the exit code (on a UNIX system).
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   runProcess "ls -l /home" >>= print
--   
--   
--   Please see the README.md 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 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.
data ProcessConfig stdin stdout stderr

-- | 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 a Handle,
--   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.
data StreamSpec (streamType :: StreamType) a

-- | 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.
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 Process use the functions from the section
--   Interact with a process.
data Process stdin stdout stderr

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

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

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

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

-- | Set the child's standard error stream to the given StreamSpec.
--   
--   Default: inherit
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 close_fds 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
--   delegate_ctlc.
--   
--   Default: False
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

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

-- | Create new console on Windows, see create_new_console.
--   
--   Default: False
setCreateNewConsole :: 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
setNewSession :: Bool -> 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
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 setuid
--   syscall, does nothing on non-POSIX. See child_user.
--   
--   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 :: forall (anyStreamType :: StreamType). 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 :: forall (anyStreamType :: StreamType). 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.
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()

-- | 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.
byteStringInput :: ByteString -> StreamSpec 'STInput ()

-- | 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.
byteStringOutput :: StreamSpec 'STOutput (STM ByteString)

-- | Create a new pipe between this process and the child, and return a
--   Handle to communicate with the child.
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle

-- | 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.
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | 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.
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | 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.
mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe 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 the
--   createProcess function. See createProcess for more
--   details.
--   
- Returns the actual stream value a, as well as a cleanup
--   function to be run when calling stopProcess.
--   
mkPipeStreamSpec :: forall a (streamType :: StreamType). (ProcessConfig () () () -> Handle -> IO (a, IO ())) -> StreamSpec streamType a

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

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

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

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

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

-- | Close a process and release any resources acquired. This will ensure
--   terminateProcess 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 runProcess, but instead of returning the
--   ExitCode, checks it with checkExitCode.
runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m ()

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

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

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

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

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

-- | Same as withProcessTerm, but also calls checkExitCode
--   
--   To interact with a Process use the functions from the section
--   Interact with a process.
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 ExitCode.
waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode

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

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

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

-- | Wait for a process to exit, and ensure that it exited successfully. If
--   not, throws an ExitCodeException.
--   
--   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 readProcess_ catch the exception,
--   add the stdout and stderr, and rethrow.
checkExitCode :: MonadIO m => Process stdin stdout stderr -> m ()

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

-- | Returns the PID (process ID) of a subprocess.
--   
--   Nothing is returned if the underlying ProcessHandle 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 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.
data ExitCodeException
ExitCodeException :: ExitCode -> ProcessConfig () () () -> ByteString -> ByteString -> ExitCodeException
[eceExitCode] :: ExitCodeException -> ExitCode
[eceProcessConfig] :: ExitCodeException -> ProcessConfig () () ()
[eceStdout] :: ExitCodeException -> ByteString
[eceStderr] :: ExitCodeException -> ByteString

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

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

-- | Wrapper for when an exception is thrown when reading from a child
--   process, used by byteStringOutput.
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 Handle will use the default
--   encoding and newline translation mode (just like Handles
--   created by openFile).
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
--   Handle that writes to /dev/null.
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 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.
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle

-- | Deprecated synonym for withProcessTerm.

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

-- | Deprecated synonym for withProcessTerm_.

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