polysemy-process-0.13.0.1: Polysemy effects for system processes
Safe HaskellSafe-Inferred
LanguageGHC2021

Polysemy.Process.SystemProcess

Description

The effect SystemProcess is a low-level abstraction of a native system process.

Synopsis

Documentation

data SystemProcess :: Effect Source #

Low-level interface for a process, operating on raw chunks of bytes. Interface is modeled after System.Process.

wait :: forall r. Member SystemProcess r => Sem r ExitCode Source #

Wait for the process to terminate, returning its exit code.

signal :: forall r. Member SystemProcess r => Signal -> Sem r () Source #

Send a Signal to the process.

withSystemProcess :: forall param err r. Member (Scoped param (SystemProcess !! err)) r => param -> InterpreterFor (SystemProcess !! err) r Source #

Create a scoped resource for SystemProcess. The process configuration may depend on the provided value of type param.

interrupt :: Member SystemProcess r => Sem r () Source #

Send signal INT(2) to the process.

pid :: forall r. Member SystemProcess r => Sem r Pid Source #

Obtain the process ID.

readStderr :: forall r. Member SystemProcess r => Sem r ByteString Source #

Read a chunk from stderr.

readStdout :: forall r. Member SystemProcess r => Sem r ByteString Source #

Read a chunk from stdout.

writeStdin :: forall r. Member SystemProcess r => ByteString -> Sem r () Source #

Write a ByteString to stdin.

type SysProcConf = ProcessConfig () () () Source #

Convenience alias for a vanilla ProcessConfig, which will usually be transformed by interpreters to use Handles.

interpretSystemProcessNative :: forall param r. Members [Resource, Embed IO] r => (param -> Sem r (Either Text SysProcConf)) -> InterpreterFor (Scoped param (SystemProcess !! SystemProcessError) !! SystemProcessScopeError) r Source #

Interpret SystemProcess as a scoped Process that's started wherever withSystemProcess is called and terminated when the wrapped action finishes. This variant is for parameterized scopes, allowing the consumer to supply a value of type param to create the process config.

currentPid :: Member (Embed IO) r => Sem r Pid Source #

Obtain the current process's Pid.