{-# options_haddock prune #-}
module Polysemy.Process.Effect.SystemProcess where
import Polysemy.Conc.Effect.Scoped (Scoped, scoped)
import Polysemy.Resume (type (!!))
import System.Exit (ExitCode)
import qualified System.Posix as Signal
import System.Posix (Signal)
import System.Process (Pid)
data SystemProcess :: Effect where
ReadStdout :: SystemProcess m ByteString
ReadStderr :: SystemProcess m ByteString
WriteStdin :: ByteString -> SystemProcess m ()
Pid :: SystemProcess m Pid
Signal :: Signal -> SystemProcess m ()
Wait :: SystemProcess m ExitCode
makeSem ''SystemProcess
withSystemProcess ::
∀ resource err r .
Member (Scoped resource (SystemProcess !! err)) r =>
InterpreterFor (SystemProcess !! err) r
withSystemProcess :: forall resource err (r :: [Effect]).
Member (Scoped resource (SystemProcess !! err)) r =>
InterpreterFor (SystemProcess !! err) r
withSystemProcess =
forall resource (effect :: Effect) (r :: [Effect]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
scoped @resource
interrupt ::
Member SystemProcess r =>
Sem r ()
interrupt :: forall (r :: [Effect]). Member SystemProcess r => Sem r ()
interrupt =
Signal -> Sem r ()
forall (r :: [Effect]).
MemberWithError SystemProcess r =>
Signal -> Sem r ()
signal Signal
Signal.sigINT
term ::
Member SystemProcess r =>
Sem r ()
term :: forall (r :: [Effect]). Member SystemProcess r => Sem r ()
term =
Signal -> Sem r ()
forall (r :: [Effect]).
MemberWithError SystemProcess r =>
Signal -> Sem r ()
signal Signal
Signal.sigTERM
kill ::
Member SystemProcess r =>
Sem r ()
kill :: forall (r :: [Effect]). Member SystemProcess r => Sem r ()
kill =
Signal -> Sem r ()
forall (r :: [Effect]).
MemberWithError SystemProcess r =>
Signal -> Sem r ()
signal Signal
Signal.sigKILL