polysemy-process-0.9.0.0: Polysemy effects for system processes
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Process.Effect.Process

Description

 
Synopsis

Documentation

data Process i o :: Effect where Source #

Abstraction of a process with input and output.

This effect is intended to be used in a scoped manner:

import Polysemy.Resume
import Polysemy.Conc
import Polysemy.Process
import qualified System.Process.Typed as System

prog :: Member (Scoped resource (Process Text Text !! err)) r => Sem r Text
prog =
 resumeAs "failed" do
   withProcess do
     send "input"
     recv

main :: IO ()
main = do
  out <- runConc $ interpretProcessNative (System.proc "cat" []) prog
  putStrLn out

Constructors

Recv :: Process i o m o 
Send :: i -> Process i o m () 

Instances

Instances details
type DefiningModule Process Source # 
Instance details

Defined in Polysemy.Process.Effect.Process

type DefiningModule Process = "Polysemy.Process.Effect.Process"

recv :: forall i o r. Member (Process i o) r => Sem r o Source #

Obtain a chunk of output.

send :: forall i o r. Member (Process i o) r => i -> Sem r () Source #

Send data to stdin.

withProcess :: forall resource i o r. Member (Scoped resource (Process i o)) r => InterpreterFor (Process i o) r Source #

Create a scoped resource for Process.

runProcessIO :: forall i o err r. Member (Process i o !! err) r => InterpretersFor [Output i !! err, Input o !! err] r Source #

Convert Output and Input to Process.