reflex-process-0.3.1.1: Reflex FRP interface for running system processes
Safe HaskellNone
LanguageHaskell2010

Reflex.Process

Description

 
Synopsis

Documentation

createProcess Source #

Arguments

:: (MonadIO m, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m), MonadFix m) 
=> CreateProcess

Specification of process to create

-> ProcessConfig t (SendPipe ByteString)

Reflex-level configuration for the process

-> m (Process t ByteString ByteString) 

Create a process feeding it input using an Event and exposing its output Events representing the process exit code, stdout, and stderr.

The stdout and stderr Handles are line-buffered.

N.B. The process input is buffered with an unbounded channel! For more control of this, use createProcessBufferingInput directly.

N.B.: The std_in, std_out, and std_err parameters of the provided CreateProcess are replaced with new pipes and all output is redirected to those pipes.

createProcessBufferingInput Source #

Arguments

:: (MonadIO m, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m), MonadFix m) 
=> IO (SendPipe ByteString)

An action that reads a value from the input stream buffer. This will run in a separate thread and must block when the buffer is empty or not ready.

-> (SendPipe ByteString -> IO ())

An action that writes a value to the input stream buffer.

-> CreateProcess

Specification of process to create

-> ProcessConfig t (SendPipe ByteString)

Reflex-level configuration for the process

-> m (Process t ByteString ByteString) 

Create a process feeding it input using an Event and exposing its output with Events for its exit code, stdout, and stderr. The input is fed via a buffer represented by a reading action and a writing action.

The stdout and stderr Handles are line-buffered.

For example, you may use Chan for an unbounded buffer (like createProcess does) like this:

 channel <- liftIO newChan
 createProcessBufferingInput (readChan channel) (writeChan channel) myConfig

Similarly you could use TChan.

Bounded buffers may cause the Reflex network to block when you trigger an Event that would cause more data to be sent to a process whose stdin is blocked.

If an unbounded channel would lead to too much memory usage you will want to consider * speeding up the consuming process. * buffering with the file system or another persistent storage to reduce memory usage. * if your usa case allows, dropping Events or messages that aren't important.

N.B.: The std_in, std_out, and std_err parameters of the provided CreateProcess are replaced with new pipes and all output is redirected to those pipes.

defProcessConfig :: Reflex t => ProcessConfig t i Source #

A default ProcessConfig where stdin and signals are never sent.

You can also use def.

unsafeCreateProcessWithHandles Source #

Arguments

:: forall t m i o e. (MonadIO m, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m)) 
=> (Handle -> IO (i -> IO ()))

Builder for the standard input handler. This is provided so you can link any new threads to this one to avoid leaking threads. The Handle is the write end of the process' stdin and the resulting i -> IO () is a function that writes each input 'Event t i' to into Handle. This function must not block or the entire Reflex network will block.

-> (Handle -> (o -> IO ()) -> IO (IO ()))

Builder for the standard output handler. The Handle is the read end of the process' stdout and the o -> IO () is a function that will trigger the output Event t o when called. The resulting IO () will be run in a separate thread and must block until there is no more data in the Handle to process.

-> (Handle -> (e -> IO ()) -> IO (IO ()))

Builder for the standard error handler. The Handle is the read end of the process' stderr and the e -> IO () is a function that will trigger the output Event t e when called. The resulting IO () will be run in a separate thread and must block until there is no more data in the Handle to process.

-> CreateProcess

Specification of process to create

-> ProcessConfig t i

Reflex-level configuration for the process

-> m (Process t o e) 

Runs a process and uses the given input and output handler functions to interact with the process via the standard streams. Used to implement createProcess.

N.B.: The std_in, std_out, and std_err parameters of the provided CreateProcess are replaced with new pipes and all output is redirected to those pipes.

data Process t o e Source #

The output of a process

Constructors

Process 

Fields

data ProcessConfig t i Source #

The inputs to a process

Constructors

ProcessConfig 

Fields

Instances

Instances details
Reflex t => Default (ProcessConfig t i) Source # 
Instance details

Defined in Reflex.Process

Methods

def :: ProcessConfig t i #

data SendPipe i Source #

Constructors

SendPipe_Message i

A message that's sent to the underlying process. This does NOT include a trailing newline when sending your message.

SendPipe_EOF

Send an EOF to the underlying process. Once this is sent no further messages will be processed.

SendPipe_LastMessage i

Send the last message along with an EOF. Once this is sent no further messages will be processed.

createRedirectedProcess :: forall t m i o e. (MonadIO m, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m)) => (Handle -> IO (i -> IO ())) -> (Handle -> (o -> IO ()) -> IO (IO ())) -> (Handle -> (e -> IO ()) -> IO (IO ())) -> CreateProcess -> ProcessConfig t i -> m (Process t o e) Source #

Deprecated: Use unsafeCreateProcessWithHandles instead.