| Safe Haskell | None |
|---|
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.
- class ListLikePlus a c => NonBlocking a c where
- hGetSome :: Handle -> LengthType a -> IO a
- toChunks :: a -> [a]
- data Output a
- foldOutput :: ListLikePlus a c => (ExitCode -> b) -> (a -> b) -> (a -> b) -> (IOError -> b) -> Output a -> b
- foldOutputsL :: ListLikePlus a c => (b -> ExitCode -> b) -> (b -> a -> b) -> (b -> a -> b) -> (b -> IOError -> b) -> b -> [Output a] -> b
- foldOutputsR :: forall a b c. ListLikePlus a c => (b -> ExitCode -> b) -> (b -> a -> b) -> (b -> a -> b) -> (b -> IOError -> b) -> b -> [Output a] -> b
- readProcessChunks :: NonBlocking a c => CreateProcess -> a -> IO [Output a]
- readProcessChunks' :: NonBlocking a c => CreateProcess -> a -> IO [Output a]
Documentation
class ListLikePlus a c => NonBlocking a c whereSource
Class of types which can also be used by readProcessChunks.
Instances
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