process-extras-0.7.4: Process extras
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Process.ListLike

Description

Re-export all symbols and instances of the process-extras package. Adds the Chunk type with a ProcessOutput instance, and a collectOutput function to turn a list of chunks into any instance of ProcessOutput, such as (ExitCode, String, String). This means you can have readCreateProcess output a list of Chunk, operate on it to do progress reporting, and finally convert it to the type that readProcessWithExitCode woud have returned.

Synopsis

Classes for process IO monad, output type, and creation type

class ListLikeIO text char => ListLikeProcessIO text char where #

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

Minimal complete definition

forceOutput, readChunks

Methods

forceOutput :: text -> IO text #

Instances

Instances details
ListLikeProcessIO Chars Char #

Like readProcessWithExitCode, but specialized for Text

Instance details

Defined in System.Process.Chars

Methods

forceOutput :: Chars -> IO Chars #

readChunks :: Handle -> IO [Chars] #

ListLikeProcessIO ByteString Word8 #

Like readProcessWithExitCode, but using ByteString

Instance details

Defined in System.Process.ByteString

Methods

forceOutput :: ByteString -> IO ByteString #

readChunks :: Handle -> IO [ByteString] #

ListLikeProcessIO ByteString Word8 #

Like readProcessWithExitCode, but using ByteString

Instance details

Defined in System.Process.ByteString.Lazy

Methods

forceOutput :: ByteString -> IO ByteString #

readChunks :: Handle -> IO [ByteString] #

ListLikeProcessIO Text Char #

Like readProcessWithExitCode, but using Text

Instance details

Defined in System.Process.Text

Methods

forceOutput :: Text -> IO Text #

readChunks :: Handle -> IO [Text] #

ListLikeProcessIO Builder Char #

Like readProcessWithExitCode, but using Text

Instance details

Defined in System.Process.Text.Builder

Methods

forceOutput :: Builder -> IO Builder #

readChunks :: Handle -> IO [Builder] #

ListLikeProcessIO Text Char #

Like readProcessWithExitCode, but using Text

Instance details

Defined in System.Process.Text.Lazy

Methods

forceOutput :: Text -> IO Text #

readChunks :: Handle -> IO [Text] #

ListLikeProcessIO String Char #

Like readProcessWithExitCode that takes a CreateProcess.

Instance details

Defined in System.Process.ListLike

Methods

forceOutput :: String -> IO String #

readChunks :: Handle -> IO [String] #

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

Instances

Instances details
ProcessText ByteString Word8 # 
Instance details

Defined in System.Process.ByteString

ProcessText ByteString Word8 # 
Instance details

Defined in System.Process.ByteString.Lazy

ProcessText Text Char # 
Instance details

Defined in System.Process.Text

ProcessText Text Char # 
Instance details

Defined in System.Process.Text.Lazy

ProcessText String Char # 
Instance details

Defined in System.Process.ListLike

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

Methods

pidf :: ProcessHandle -> result #

outf :: text -> result #

errf :: text -> result #

intf :: SomeException -> result #

codef :: ExitCode -> result #

Instances

Instances details
ListLikeProcessIO a c => ProcessResult a [Chunk a] # 
Instance details

Defined in System.Process.ListLike

Methods

pidf :: ProcessHandle -> [Chunk a] #

outf :: a -> [Chunk a] #

errf :: a -> [Chunk a] #

intf :: SomeException -> [Chunk a] #

codef :: ExitCode -> [Chunk a] #

ListLikeProcessIO a c => ProcessResult a (ExitCode, [Chunk a]) # 
Instance details

Defined in System.Process.ListLike

Methods

pidf :: ProcessHandle -> (ExitCode, [Chunk a]) #

outf :: a -> (ExitCode, [Chunk a]) #

errf :: a -> (ExitCode, [Chunk a]) #

intf :: SomeException -> (ExitCode, [Chunk a]) #

codef :: ExitCode -> (ExitCode, [Chunk a]) #

ListLikeProcessIO text char => ProcessResult text (ExitCode, text, text) # 
Instance details

Defined in System.Process.Common

Methods

pidf :: ProcessHandle -> (ExitCode, text, text) #

outf :: text -> (ExitCode, text, text) #

errf :: text -> (ExitCode, text, text) #

intf :: SomeException -> (ExitCode, text, text) #

codef :: ExitCode -> (ExitCode, text, text) #

class ProcessMaker a where #

Methods

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

showProcessMakerForUser :: a -> String #

Instances

Instances details
ProcessMaker CreateProcess #

This is the usual maker argument to readCreateProcessLazy.

Instance details

Defined in System.Process.Common

Methods

process :: CreateProcess -> IO (Handle, Handle, Handle, ProcessHandle) #

showProcessMakerForUser :: CreateProcess -> String #

ProcessMaker (CreateProcess, BufferMode, BufferMode) #

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) #

showProcessMakerForUser :: (CreateProcess, BufferMode, BufferMode) -> String #

The generalized process runners

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

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 #

Like readCreateProcessStrict, but the output is read lazily.

readCreateProcessWithExitCode #

Arguments

:: (ProcessMaker maker, ListLikeProcessIO text char) 
=> maker

command and arguments to run

-> text

standard input

-> IO (ExitCode, text, text)

exitcode, stdout, stderr

readProcessWithExitCode #

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.

Utility functions based on showCommandForUser

showCreateProcessForUser :: CreateProcess -> String #

System.Process utility functions.

The Chunk type

data Chunk a #

This type is a concrete representation of the methods of class ProcessOutput. If you take your process output as this type you could, for example, echo all the output and then use collectOutput below to convert it to any other instance of ProcessOutput.

Constructors

ProcessHandle ProcessHandle

This will always come first, before any output or exit code.

Stdout a 
Stderr a 
Result ExitCode 
Exception SomeException

Note that the instances below do not use this constructor.

Instances

Instances details
ListLikeProcessIO a c => ProcessResult a [Chunk a] # 
Instance details

Defined in System.Process.ListLike

Methods

pidf :: ProcessHandle -> [Chunk a] #

outf :: a -> [Chunk a] #

errf :: a -> [Chunk a] #

intf :: SomeException -> [Chunk a] #

codef :: ExitCode -> [Chunk a] #

ListLikeProcessIO a c => ProcessResult a (ExitCode, [Chunk a]) # 
Instance details

Defined in System.Process.ListLike

Methods

pidf :: ProcessHandle -> (ExitCode, [Chunk a]) #

outf :: a -> (ExitCode, [Chunk a]) #

errf :: a -> (ExitCode, [Chunk a]) #

intf :: SomeException -> (ExitCode, [Chunk a]) #

codef :: ExitCode -> (ExitCode, [Chunk a]) #

Show a => Show (Chunk a) # 
Instance details

Defined in System.Process.ListLike

Methods

showsPrec :: Int -> Chunk a -> ShowS

show :: Chunk a -> String

showList :: [Chunk a] -> ShowS

collectOutput :: ProcessResult a b => [Chunk a] -> b #

Turn a [Chunk a] into any other instance of ProcessOutput. I usually use this after processing the chunk list to turn it into the (ExitCode, String, String) type returned by readProcessWithExitCode.

foldOutput #

Arguments

:: (ProcessHandle -> r)

called when the process handle becomes known

-> (a -> r)

stdout handler

-> (a -> r)

stderr handler

-> (SomeException -> r)

exception handler

-> (ExitCode -> r)

exit code handler

-> Chunk a 
-> r 

writeOutput :: ListLikeIO a c => [Chunk a] -> IO [Chunk a] #

Send Stdout chunks to stdout and Stderr chunks to stderr. Returns input list unmodified.

writeChunk :: ListLikeIO a c => Chunk a -> IO (Chunk a) #

Re-exports from process

data CmdSpec #

Constructors

ShellCommand String 
RawCommand FilePath [String] 

Instances

Instances details
IsString CmdSpec 
Instance details

Defined in System.Process.Common

Methods

fromString :: String -> CmdSpec #

Show CmdSpec 
Instance details

Defined in System.Process.Common

Methods

showsPrec :: Int -> CmdSpec -> ShowS

show :: CmdSpec -> String

showList :: [CmdSpec] -> ShowS

Eq CmdSpec 
Instance details

Defined in System.Process.Common

Methods

(==) :: CmdSpec -> CmdSpec -> Bool

(/=) :: CmdSpec -> CmdSpec -> Bool

data CreateProcess #

Constructors

CreateProcess 

Fields

Instances

Instances details
Show CreateProcess 
Instance details

Defined in System.Process.Common

Methods

showsPrec :: Int -> CreateProcess -> ShowS

show :: CreateProcess -> String

showList :: [CreateProcess] -> ShowS

Eq CreateProcess 
Instance details

Defined in System.Process.Common

ProcessMaker CreateProcess #

This is the usual maker argument to readCreateProcessLazy.

Instance details

Defined in System.Process.Common

Methods

process :: CreateProcess -> IO (Handle, Handle, Handle, ProcessHandle) #

showProcessMakerForUser :: CreateProcess -> String #

ProcessMaker (CreateProcess, BufferMode, BufferMode) #

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) #

showProcessMakerForUser :: (CreateProcess, BufferMode, BufferMode) -> String #

proc :: FilePath -> [String] -> CreateProcess #

shell :: String -> CreateProcess #

showCommandForUser :: FilePath -> [String] -> String #

Orphan instances

Show ProcessHandle # 
Instance details

Methods

showsPrec :: Int -> ProcessHandle -> ShowS

show :: ProcessHandle -> String

showList :: [ProcessHandle] -> ShowS

ListLikeProcessIO String Char #

Like readProcessWithExitCode that takes a CreateProcess.

Instance details

Methods

forceOutput :: String -> IO String #

readChunks :: Handle -> IO [String] #

ProcessText String Char # 
Instance details