process-extras-0.7.4: Process extras

Safe Haskell | None
Language | Haskell2010

System.Process.Common

Contents

- Orphan instances

Synopsis

- class ProcessMaker a where
  - process :: a -> IO (Handle, Handle, Handle, ProcessHandle)
  - showProcessMakerForUser :: a -> String
- class ListLikeIO text char => ListLikeProcessIO text char where
  - forceOutput :: text -> IO text
  - readChunks :: Handle -> IO [text]
- class (IsString text, Monoid text, ListLike text char) => ProcessText text char
- class Monoid result => ProcessResult text result | result -> text where
  - pidf :: ProcessHandle -> result
  - outf :: text -> result
  - errf :: text -> result
  - intf :: SomeException -> result
  - codef :: ExitCode -> result
- readProcessWithExitCode :: ListLikeProcessIO text char => FilePath -> [String] -> text -> IO (ExitCode, text, text)
- readCreateProcessWithExitCode :: (ProcessMaker maker, ListLikeProcessIO text char) => maker -> text -> IO (ExitCode, text, text)
- readCreateProcessStrict :: (ProcessMaker maker, ProcessResult text result, ListLikeProcessIO text char) => maker -> text -> IO result
- readCreateProcessLazy :: (ProcessMaker maker, ProcessResult a b, ListLikeProcessIO a c) => maker -> a -> IO b
- showCmdSpecForUser :: CmdSpec -> String
- showCreateProcessForUser :: CreateProcess -> String

# Documentation

class ProcessMaker a where Source #

Methods

process :: a -> IO (Handle, Handle, Handle, ProcessHandle) Source #

showProcessMakerForUser :: a -> String Source #

#### Instances

Instances details

ProcessMaker CreateProcess Source # | This is the usual maker argument to `readCreateProcessLazy`.
Instance details Defined in System.Process.Common Methods process :: CreateProcess -> IO (Handle, Handle, Handle, ProcessHandle) Source # showProcessMakerForUser :: CreateProcess -> String Source #
ProcessMaker (CreateProcess, BufferMode, BufferMode) Source # | Passing this to `readCreateProcessLazy` as the maker argument allows you to set the buffer mode of the process stdout and stderr handles just after the handles are created. These are set to BlockBuffering by default, but for running console commands LineBuffering is probably what you want.
Instance details Defined in System.Process.Common Methods process :: (CreateProcess, BufferMode, BufferMode) -> IO (Handle, Handle, Handle, ProcessHandle) Source # showProcessMakerForUser :: (CreateProcess, BufferMode, BufferMode) -> String Source #

class ListLikeIO text char => ListLikeProcessIO text char where Source #

Process IO is based on the `ListLikeIO` class from the ListLike package

Methods

forceOutput :: text -> IO text Source #

readChunks :: Handle -> IO [text] Source #

Read from a handle, returning a lazy list of the monoid a.

#### Instances

Instances details

ListLikeProcessIO Chars Char Source # | Like `readProcessWithExitCode`, but specialized for `Text`
Instance details Defined in System.Process.Chars Methods forceOutput :: Chars -> IO Chars Source # readChunks :: Handle -> IO [Chars] Source #
ListLikeProcessIO ByteString Word8 Source # | Like `readProcessWithExitCode`, but using `ByteString`
Instance details Defined in System.Process.ByteString Methods forceOutput :: ByteString -> IO ByteString Source # readChunks :: Handle -> IO [ByteString] Source #
ListLikeProcessIO ByteString Word8 Source # | Like `readProcessWithExitCode`, but using `ByteString`
Instance details Defined in System.Process.ByteString.Lazy Methods forceOutput :: ByteString -> IO ByteString Source # readChunks :: Handle -> IO [ByteString] Source #
ListLikeProcessIO Text Char Source # | Like `readProcessWithExitCode`, but using `Text`
Instance details Defined in System.Process.Text Methods forceOutput :: Text -> IO Text Source # readChunks :: Handle -> IO [Text] Source #
ListLikeProcessIO Builder Char Source # | Like `readProcessWithExitCode`, but using `Text`
Instance details Defined in System.Process.Text.Builder Methods forceOutput :: Builder -> IO Builder Source # readChunks :: Handle -> IO [Builder] Source #
ListLikeProcessIO Text Char Source # | Like `readProcessWithExitCode`, but using `Text`
Instance details Defined in System.Process.Text.Lazy Methods forceOutput :: Text -> IO Text Source # readChunks :: Handle -> IO [Text] Source #
ListLikeProcessIO String Char Source # | Like `readProcessWithExitCode` that takes a `CreateProcess`.
Instance details Defined in System.Process.ListLike Methods forceOutput :: String -> IO String Source # readChunks :: Handle -> IO [String] Source #

class (IsString text, Monoid text, ListLike text char) => ProcessText text char Source #

#### Instances

Instances details

ProcessText ByteString Word8 Source # |
Instance details Defined in System.Process.ByteString
ProcessText ByteString Word8 Source # |
Instance details Defined in System.Process.ByteString.Lazy
ProcessText Text Char Source # |
Instance details Defined in System.Process.Text
ProcessText Text Char Source # |
Instance details Defined in System.Process.Text.Lazy
ProcessText String Char Source # |
Instance details Defined in System.Process.ListLike

class Monoid result => ProcessResult text result | result -> text where Source #

Methods

pidf :: ProcessHandle -> result Source #

outf :: text -> result Source #

errf :: text -> result Source #

intf :: SomeException -> result Source #

codef :: ExitCode -> result Source #

#### Instances

Instances details

ListLikeProcessIO a c => ProcessResult a [Chunk a] Source # |
Instance details Defined in System.Process.ListLike Methods pidf :: ProcessHandle -> [Chunk a] Source # outf :: a -> [Chunk a] Source # errf :: a -> [Chunk a] Source # intf :: SomeException -> [Chunk a] Source # codef :: ExitCode -> [Chunk a] Source #
ListLikeProcessIO a c => ProcessResult a (ExitCode, [Chunk a]) Source # |
Instance details Defined in System.Process.ListLike Methods pidf :: ProcessHandle -> (ExitCode, [Chunk a]) Source # outf :: a -> (ExitCode, [Chunk a]) Source # errf :: a -> (ExitCode, [Chunk a]) Source # intf :: SomeException -> (ExitCode, [Chunk a]) Source # codef :: ExitCode -> (ExitCode, [Chunk a]) Source #
ListLikeProcessIO text char => ProcessResult text (ExitCode, text, text) Source # |
Instance details Defined in System.Process.Common Methods pidf :: ProcessHandle -> (ExitCode, text, text) Source # outf :: text -> (ExitCode, text, text) Source # errf :: text -> (ExitCode, text, text) Source # intf :: SomeException -> (ExitCode, text, text) Source # codef :: ExitCode -> (ExitCode, text, text) Source #

readProcessWithExitCode Source #

Arguments

:: ListLikeProcessIO text char |
=> FilePath | command to run
-> [String] | any arguments
-> text | standard input
-> IO (ExitCode, text, text) | exitcode, stdout, stderr

Like `readProcessWithExitCode`, but with generalized input and output type. Aside from the usual text-like types, the output can be a list of Chunk a. This lets you process the chunks received from stdout and stderr lazil, in the order they are received, as well as the exit code. Utilities to handle Chunks are provided in System.Process.ListLike.

readCreateProcessWithExitCode Source #

Arguments

:: (ProcessMaker maker, ListLikeProcessIO text char) |
=> maker | command and arguments to run
-> text | standard input
-> IO (ExitCode, text, text) | exitcode, stdout, stderr

readCreateProcessStrict :: (ProcessMaker maker, ProcessResult text result, ListLikeProcessIO text char) => maker -> text -> IO result Source #

readCreateProcessLazy :: (ProcessMaker maker, ProcessResult a b, ListLikeProcessIO a c) => maker -> a -> IO b Source #

Like readCreateProcessStrict, but the output is read lazily.

showCmdSpecForUser :: CmdSpec -> String Source #

showCreateProcessForUser :: CreateProcess -> String Source #

System.Process utility functions.

# Orphan instances

Monoid ExitCode Source # | A process usually has one `ExitCode` at the end of its output, this `Monoid` instance lets us build the type returned by `readProcessWithExitCode`.
Instance details Methods mempty :: ExitCode Source # mappend :: ExitCode -> ExitCode -> ExitCode Source # mconcat :: [ExitCode] -> ExitCode Source #
Semigroup ExitCode Source # |
Instance details Methods (<>) :: ExitCode -> ExitCode -> ExitCode Source # sconcat :: NonEmpty ExitCode -> ExitCode Source # stimes :: Integral b => b -> ExitCode -> ExitCode Source #