process-listlike-0.10: Process extras

Safe HaskellNone

System.Process.ListLike.Read

Description

Generalized versions of the functions readProcess, and readProcessWithExitCode.

Synopsis

Documentation

readCreateProcess :: (ListLikeLazyIO a c, ProcessOutput a b) => CreateProcess -> a -> IO bSource

Read the output of a process and use the argument functions to convert it into a Monoid, preserving the order of appearance of the different chunks of output from standard output and standard error.

readCreateProcess' :: (ListLikeLazyIO a c, ProcessOutput a b) => CreateProcess -> a -> IO bSource

readInterleaved :: forall a b c. (ListLikeLazyIO a c, ProcessOutput a b) => [(a -> b, Handle)] -> IO b -> IO bSource

Simultaneously read the output from several file handles, using the associated functions to add them to a Monoid b in the order they appear. This closes each handle on EOF, because AFAIK it is the only useful thing to do with a file handle that has reached EOF.

readCreateProcessWithExitCodeSource

Arguments

:: ListLikeLazyIO a c 
=> CreateProcess

process to run

-> a

standard input

-> IO (ExitCode, a, a)

exitcode, stdout, stderr

An implementation of readProcessWithExitCode with a two generalizations: (1) The input and outputs can be any instance of ListLikeLazyIO, and (2) The CreateProcess is passes an argument, so you can use either proc or rawSystem and you can modify its fields such as cwd before the process starts

readProcessWithExitCodeSource

Arguments

:: ListLikeLazyIO a c 
=> FilePath

command to run

-> [String]

any arguments

-> a

standard input

-> IO (ExitCode, a, a)

exitcode, stdout, stderr

A version of readProcessWithExitCode that uses any instance of ListLikeLazyIO instead of String, implemented using readCreateProcessWithExitCode.

newtype StdoutWrapper a Source

For the readProcess function, we need to wrap a newtype around the output type so we can build a ProcessOutput instance for it. Otherwise it would overlap everything.

Constructors

StdoutWrapper 

Fields

unStdoutWrapper :: a
 

Instances

(ListLikeLazyIO a c, Monoid a) => ProcessOutput a (StdoutWrapper a) 
Monoid a => Monoid (StdoutWrapper a) 

readProcessSource

Arguments

:: ListLikeLazyIO a c 
=> FilePath

command to run

-> [String]

any arguments

-> a

standard input

-> IO a

stdout

Implementation of readProcess that uses any instance of ListLikeLazyIO instead of String, implemented using readCreateProcess. As with readProcess, Stderr goes directly to the console, only stdout is returned. Also like readProcess, an IO error of type OtherError is thrown when the result code is not ExitSuccess.