diff options
Diffstat (limited to 'src/Flameshot/Internal')
-rw-r--r-- | src/Flameshot/Internal/Process.hs | 34 |
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 |