summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-05-01 09:24:15 +0200
committertv <tv@krebsco.de>2020-05-01 09:24:15 +0200
commita8da209ee5d0fe44b9d704b9fc7812e4a96c1888 (patch)
tree6f9b2ecc86660db5030fcb15521190526a420a4d /src
parent54ffbdc61c63a75c988c990909bab1c007b19e0c (diff)
Flameshot.Internal.Process: monoidify Callbacks
Diffstat (limited to 'src')
-rw-r--r--src/Flameshot/Internal/Process.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Flameshot/Internal/Process.hs b/src/Flameshot/Internal/Process.hs
index 47220a3..e38a145 100644
--- a/src/Flameshot/Internal/Process.hs
+++ b/src/Flameshot/Internal/Process.hs
@@ -36,6 +36,40 @@ data Callbacks = Callbacks
, onStart :: Pid -> IO ()
}
+instance Semigroup Callbacks where
+ a <> b =
+ Callbacks
+ { onOutLine = \pid s -> do
+ onOutLine a pid s
+ onOutLine b pid s
+
+ , onErrLine = \pid s -> do
+ onErrLine a pid s
+ onErrLine b pid s
+
+ , onError = \pid err -> do
+ onError a pid err
+ onError b pid err
+
+ , onExit = \pid status -> do
+ onExit a pid status
+ onExit b pid status
+
+ , onStart = \pid -> do
+ onStart a pid
+ onStart b pid
+ }
+
+instance Monoid Callbacks where
+ mempty =
+ Callbacks
+ { onOutLine = \_pid _s -> return ()
+ , onErrLine = \_pid _s -> return ()
+ , onError = \_pid _err -> return ()
+ , onExit = \_pid _status -> return ()
+ , onStart = \_pid -> return ()
+ }
+
run :: FilePath
-> [String]
-> Maybe FilePath