aboutsummaryrefslogtreecommitdiffstats
path: root/src/Process/Shell.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Process/Shell.hs')
-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