process-progress-0.9: Run a process and do reportsing on its progress.

Safe HaskellNone

System.Process.Read.Chunks

Description

The readProcessChunks function is a process reader that returns a list (stream) of Output, which represent chunks of text read from Stdout, Stderr, a Result code, or an Exception. This has the advantage of preserving the order in which these things appeared. The foldOutput, foldOutputsL, and foldOutputsR functions can be used to process the output stream. The output text can be any NonBlocking instance, which needs to be implemented using a non-blocking read function like hGetSome.

Synopsis

Documentation

class ListLikePlus a c => NonBlocking a c whereSource

Class of types which can also be used by readProcessChunks.

Methods

hGetSome :: Handle -> LengthType a -> IO aSource

toChunks :: a -> [a]Source

data Output a Source

Instances

Eq a => Eq (Output a) 
Show a => Show (Output a) 

foldOutput :: ListLikePlus a c => (ExitCode -> b) -> (a -> b) -> (a -> b) -> (IOError -> b) -> Output a -> bSource

A fold function for the Output type, dispatches the value depending on the constructor.

foldOutputsL :: ListLikePlus a c => (b -> ExitCode -> b) -> (b -> a -> b) -> (b -> a -> b) -> (b -> IOError -> b) -> b -> [Output a] -> bSource

foldOutputsR :: forall a b c. ListLikePlus a c => (b -> ExitCode -> b) -> (b -> a -> b) -> (b -> a -> b) -> (b -> IOError -> b) -> b -> [Output a] -> bSource

readProcessChunks :: NonBlocking a c => CreateProcess -> a -> IO [Output a]Source

This is a process runner which (at the cost of a busy loop) gives you the chunks of text read from stdout and stderr interleaved in the order they were written, along with any ResourceVanished exxception that might occur. Its interface is similar to readModifiedProcessWith, though the implementation is somewhat alarming.

readProcessChunks' :: NonBlocking a c => CreateProcess -> a -> IO [Output a]Source

A test version of readProcessChunks. Pipes code here: http:hpaste.org/76631