aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-07 03:57:03 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-07 03:57:03 +0100
commit805d47c4b5db311601f499732e9492341cdd270c (patch)
treeaf329b08f94390ec12ba8054aedc8395930994da /src
parentb57f3a35f23aae1b327b46a002201aa32edc525c (diff)
chore: run `sh` in `MonadIO`
Diffstat (limited to 'src')
-rw-r--r--src/Process/Shell.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Process/Shell.hs b/src/Process/Shell.hs
index 94ba3c9..63d2f8a 100644
--- a/src/Process/Shell.hs
+++ b/src/Process/Shell.hs
@@ -11,6 +11,7 @@ module Process.Shell
where
import Control.Monad
+import Control.Monad.Trans
import Data.ByteString qualified as B
import Data.ByteString.Lazy qualified as LB
import Data.ByteString.Lazy.UTF8 qualified as LB
@@ -35,21 +36,23 @@ class Processable a r where
instance (Processable a r) => Processable (String -> a) (String -> r) where
sh_ f x = sh_ (f x)
-instance Processable String (IO ()) where
+instance (MonadIO m) => Processable String (m ()) where
sh_ s = do
- runProcess_ (fromString s)
+ liftIO (runProcess_ (fromString s))
-instance (Outputable a) => Processable String (IO a) where
+instance (MonadIO m, Outputable a) => Processable String (m a) where
sh_ s = do
- fromLBS <$> readProcessInterleaved_ (fromString s)
+ fromLBS <$> liftIO (readProcessInterleaved_ (fromString s))
-instance (Outputable stdout, Outputable stderr) => Processable String (IO (stdout, stderr)) where
+instance (MonadIO m, Outputable stdout, Outputable stderr) => Processable String (m (stdout, stderr)) where
sh_ s = do
- (\(out, err) -> (fromLBS out, fromLBS err)) <$> readProcess_ (fromString s)
+ (\(out, err) -> (fromLBS out, fromLBS err))
+ <$> liftIO (readProcess_ (fromString s))
-instance (Outputable stdout, Outputable stderr) => Processable String (IO (ExitCode, stdout, stderr)) where
+instance (MonadIO m, Outputable stdout, Outputable stderr) => Processable String (m (ExitCode, stdout, stderr)) where
sh_ s = do
- (\(exitCode, out, err) -> (exitCode, fromLBS out, fromLBS err)) <$> readProcess (fromString s)
+ (\(exitCode, out, err) -> (exitCode, fromLBS out, fromLBS err))
+ <$> liftIO (readProcess (fromString s))
class Outputable a where
fromLBS :: LB.ByteString -> a