{-# options_haddock prune #-}
module Helic.Tmux where
import Polysemy.Conc (Scoped)
import qualified Polysemy.Log as Log
import Polysemy.Log (Log)
import qualified Polysemy.Process as Process
import Polysemy.Process (Process)
import Polysemy.Process.Effect.Process (withProcess)
import Polysemy.Resume (type (!!), (!!))
import Helic.Data.Event (Event (Event))
sendToTmux ::
∀ err o e resource r .
Show err =>
Members [Scoped resource (Process ByteString o e !! err), Log] r =>
Event ->
Sem r ()
sendToTmux :: Event -> Sem r ()
sendToTmux (Event InstanceName
_ AgentId
_ Time
_ Text
text) =
Sem ((Process ByteString o e !! err) : r) () -> Sem r ()
forall resource i o e err (r :: EffectRow).
Member (Scoped resource (Process i o e !! err)) r =>
InterpreterFor (Process i o e !! err) r
withProcess do
ByteString
-> Sem
(Process ByteString o e : (Process ByteString o e !! err) : r) ()
forall i o e (r :: EffectRow).
Member (Process i o e) r =>
i -> Sem r ()
Process.send (Text -> ByteString
forall a b. ConvertUtf8 a b => a -> b
encodeUtf8 Text
text) Sem
(Process ByteString o e : (Process ByteString o e !! err) : r) ()
-> (err -> Sem ((Process ByteString o e !! err) : r) ())
-> Sem ((Process ByteString o e !! err) : r) ()
forall err (eff :: Effect) (r :: EffectRow) a.
Member (Resumable err eff) r =>
Sem (eff : r) a -> (err -> Sem r a) -> Sem r a
!! \ err
e ->
Text -> Sem ((Process ByteString o e !! err) : r) ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
Log.error [exon|failed to send data to tmux: #{show e}|]