-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Process extras
--
-- Extra functionality for the Process library
-- http://hackage.haskell.org/package/process.
@package process-listlike
@version 0.10
module System.Process.ListLike.Classes
-- | Class of types which can be used as the input and outputs of these
-- process functions.
class ListLikeIO a c => ListLikeLazyIO a c
readChunks :: ListLikeLazyIO a c => Handle -> IO [a]
-- | Methods for turning the output of a process into a monoid.
class Monoid b => ProcessOutput a b | b -> a
pidf :: ProcessOutput a b => ProcessHandle -> b
outf :: ProcessOutput a b => a -> b
errf :: ProcessOutput a b => a -> b
intf :: ProcessOutput a b => SomeException -> b
codef :: ProcessOutput a b => ExitCode -> b
instance Monoid ExitCode
-- | ListLikeLazyIO instances for strict and lazy types. If you start a
-- long running process with a strict type it will block until the
-- process finishes. Why not try a lazy type?
module System.Process.ListLike.Instances
instance ListLikeLazyIO a c => ProcessOutput a (ExitCode, a, a)
instance ListLikeLazyIO Text Char
instance ListLikeLazyIO ByteString Word8
instance ListLikeLazyIO Text Char
instance ListLikeLazyIO ByteString Word8
-- | Generalized versions of the functions readProcess, and
-- readProcessWithExitCode.
module System.Process.ListLike.Read
-- | 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 b
readCreateProcess' :: (ListLikeLazyIO a c, ProcessOutput a b) => CreateProcess -> a -> IO b
-- | 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.
readInterleaved :: (ListLikeLazyIO a c, ProcessOutput a b) => [(a -> b, Handle)] -> IO b -> IO b
-- | 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
readCreateProcessWithExitCode :: ListLikeLazyIO a c => CreateProcess -> a -> IO (ExitCode, a, a)
-- | A version of readProcessWithExitCode that uses any instance of
-- ListLikeLazyIO instead of String, implemented using
-- readCreateProcessWithExitCode.
readProcessWithExitCode :: ListLikeLazyIO a c => FilePath -> [String] -> a -> IO (ExitCode, a, a)
-- | 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.
newtype StdoutWrapper a
StdoutWrapper :: a -> StdoutWrapper a
unStdoutWrapper :: StdoutWrapper a -> a
-- | 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.
readProcess :: ListLikeLazyIO a c => FilePath -> [String] -> a -> IO a
instance (ListLikeLazyIO a c, Monoid a) => ProcessOutput a (StdoutWrapper a)
instance Monoid a => Monoid (StdoutWrapper a)
module System.Process.ByteString.Lazy
readCreateProcess :: ProcessOutput ByteString b => CreateProcess -> ByteString -> IO b
-- | Like readProcessWithExitCode, but takes a CreateProcess instead
-- of a command and argument list, and reads and writes type
-- ByteString
readCreateProcessWithExitCode :: CreateProcess -> ByteString -> IO (ExitCode, ByteString, ByteString)
-- | Like readProcessWithExitCode, but using ByteString
readProcessWithExitCode :: FilePath -> [String] -> ByteString -> IO (ExitCode, ByteString, ByteString)
-- | Like readProcess, but using ByteString
readProcess :: FilePath -> [String] -> ByteString -> IO ByteString
-- | Support for using the Chunk list returned by
-- readProcessChunks.
module System.Process.Chunks
-- | A concrete representation of the methods in ProcessOutput.
data Chunk a
-- | This will always come first
ProcessHandle :: ProcessHandle -> Chunk a
Stdout :: a -> Chunk a
Stderr :: a -> Chunk a
Exception :: SomeException -> Chunk a
Result :: ExitCode -> Chunk a
-- | A concrete use of readCreateProcess - build a list containing
-- chunks of process output, any exceptions that get thrown, and finally
-- an exit code. If a is a lazy type the returned list will be lazy.
readCreateProcessChunks :: ListLikeLazyIO a c => CreateProcess -> a -> IO [Chunk a]
-- | Eliminate empty Stdout or Stderr chunks.
discardEmptyChunks :: ListLikeLazyIO a c => [Chunk a] -> [Chunk a]
-- | Merge adjacent Stdout or Stderr chunks. This may be undesirable if you
-- want to get your input as soon as it becomes available, it has the
-- effect of making the result less lazy.
fuseChunks :: ListLikeLazyIO a c => [Chunk a] -> [Chunk a]
collectProcessTriple :: Monoid a => [Chunk a] -> (ExitCode, a, a)
collectProcessResult :: Monoid a => [Chunk a] -> (ExitCode, [Chunk a])
collectProcessOutput :: Monoid a => [Chunk a] -> (ExitCode, a)
-- | Pure function to indent the text of a chunk list.
indentChunks :: (ListLikeLazyIO a c, Eq c, IsString a) => String -> String -> [Chunk a] -> [Chunk a]
dotifyChunks :: ListLikeLazyIO a c => Int -> c -> [Chunk a] -> [Chunk a]
-- | Write the Stdout chunks to stdout and the Stderr chunks to stderr.
putChunk :: ListLikeLazyIO a c => Chunk a -> IO ()
-- | Apply a function to the chunk list and output the result, return the
-- original (unmodified) chunk list.
putMappedChunks :: ListLikeLazyIO a c => ([Chunk a] -> [Chunk a]) -> [Chunk a] -> IO [Chunk a]
-- | Output the indented text of a chunk list, but return the original
-- unindented list.
putIndented :: (ListLikeLazyIO a c, Eq c, IsString a) => String -> String -> [Chunk a] -> IO [Chunk a]
putIndentedShowCommand :: (ListLikeLazyIO a c, Eq c, IsString a) => CreateProcess -> String -> String -> [Chunk a] -> IO [Chunk a]
-- | Output the dotified text of a chunk list. Returns the original
-- (undotified) list.
putDots :: ListLikeLazyIO a c => Int -> c -> [Chunk a] -> IO [Chunk a]
-- | Output the dotified text of a chunk list with a newline at EOF.
-- Returns the original list.
putDotsLn :: (IsString a, ListLikeLazyIO a c) => Int -> c -> [Chunk a] -> IO [Chunk a]
-- | Insert a chunk displaying the command and its arguments at the
-- beginning of the chunk list.
insertCommandStart :: (IsString a, ListLikeLazyIO a c, Eq c) => CreateProcess -> [Chunk a] -> [Chunk a]
-- | Insert a chunk displaying the command and the result code.
insertCommandResult :: (IsString a, ListLikeLazyIO a c, Eq c) => CreateProcess -> [Chunk a] -> [Chunk a]
insertCommandDisplay :: (IsString a, ListLikeLazyIO a c, Eq c) => CreateProcess -> [Chunk a] -> [Chunk a]
showCreateProcessForUser :: CreateProcess -> String
showCmdSpecForUser :: CmdSpec -> String
instance Eq BOL
instance NFData ExitCode
instance ListLikeLazyIO a c => ProcessOutput a (ExitCode, [Chunk a])
instance ListLikeLazyIO a c => ProcessOutput a [Chunk a]
module System.Process.ListLike.LazyString
instance ListLikeLazyIO String Char
-- | This is an alternative version of the module
-- System.Process.ListLike.Read that doesn't use forkIO. I don't
-- know of any advantages, I'm just including it because it is derived
-- from old code I had developed, it is kinda badass, and maybe someone
-- has a use for it.
--
-- Function to run a process and return a lazy list of chunks from
-- standard output, standard error, and at the end of the list an object
-- indicating the process result code. If neither output handle is ready
-- for reading the process sleeps and tries again, with the sleep
-- intervals increasing from 8 microseconds to a maximum of 0.1 seconds.
module System.Process.ListLike.ReadNoThreads
-- | For the unthreaded implementation we need a more powerful
-- ListLikeLazyIO class.
class ListLikeLazyIO a c => ListLikeIOPlus a c
hPutNonBlocking :: ListLikeIOPlus a c => Handle -> a -> IO a
chunks :: ListLikeIOPlus a c => a -> [a]
readCreateProcess :: (ListLikeIOPlus a c, ProcessOutput a b) => CreateProcess -> a -> IO b
readCreateProcessWithExitCode :: ListLikeIOPlus a c => CreateProcess -> a -> IO (ExitCode, a, a)
readProcessWithExitCode :: ListLikeIOPlus a c => FilePath -> [String] -> a -> IO (ExitCode, a, a)
instance Eq Readyness
instance ListLikeIOPlus Text Char
instance ListLikeIOPlus ByteString Word8
module System.Process.ListLike.StrictString
instance ListLikeLazyIO String Char
module System.Process.String
readCreateProcess :: (ListLikeLazyIO String Char, ProcessOutput String b) => CreateProcess -> String -> IO b
readCreateProcessWithExitCode :: ListLikeLazyIO String Char => CreateProcess -> String -> IO (ExitCode, String, String)
module System.Process.Text
readCreateProcess :: ProcessOutput Text b => CreateProcess -> Text -> IO b
-- | Like readProcessWithExitCode, but takes a CreateProcess instead
-- of a command and argument list, and reads and writes type
-- ByteString
readCreateProcessWithExitCode :: CreateProcess -> Text -> IO (ExitCode, Text, Text)
-- | Like readProcessWithExitCode, but using ByteString
readProcessWithExitCode :: FilePath -> [String] -> Text -> IO (ExitCode, Text, Text)
-- | Like readProcess, but using Text
readProcess :: FilePath -> [String] -> Text -> IO Text
module System.Process.Text.Lazy
readCreateProcess :: ProcessOutput Text b => CreateProcess -> Text -> IO b
-- | Like readProcessWithExitCode, but using Text
readCreateProcessWithExitCode :: CreateProcess -> Text -> IO (ExitCode, Text, Text)
-- | Like readProcessWithExitCode, but using ByteString
readProcessWithExitCode :: FilePath -> [String] -> Text -> IO (ExitCode, Text, Text)
-- | Like readProcess, but using Text
readProcess :: FilePath -> [String] -> Text -> IO Text
module System.Process.ListLike
module System.Process.ByteString
readCreateProcess :: ProcessOutput ByteString b => CreateProcess -> ByteString -> IO b
-- | Like readProcessWithExitCode, but takes a CreateProcess instead
-- of a command and argument list, and reads and writes type
-- ByteString
readCreateProcessWithExitCode :: CreateProcess -> ByteString -> IO (ExitCode, ByteString, ByteString)
-- | Like readProcessWithExitCode, but using ByteString
readProcessWithExitCode :: FilePath -> [String] -> ByteString -> IO (ExitCode, ByteString, ByteString)
-- | Like readProcess, but using ByteString
readProcess :: FilePath -> [String] -> ByteString -> IO ByteString