{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable, OverloadedStrings,
             FlexibleInstances, FlexibleContexts, IncoherentInstances,
             TypeFamilies, ExistentialQuantification, RankNTypes,
             ImpredicativeTypes #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- | A module for shell-like programming in Haskell.
-- Shelly's focus is entirely on ease of use for those coming from shell scripting.
-- However, it also tries to use modern libraries and techniques to keep things efficient.
--
-- The functionality provided by
-- this module is (unlike standard Haskell filesystem functionality)
-- thread-safe: each Sh maintains its own environment and its own working
-- directory.
--
-- Recommended usage includes putting the following at the top of your program,
-- otherwise you will likely need either type annotations or type conversions
--
-- > {-# LANGUAGE OverloadedStrings #-}
-- > {-# LANGUAGE ExtendedDefaultRules #-}
-- > {-# OPTIONS_GHC -fno-warn-type-defaults #-}
-- > import Shelly
-- > import qualified Data.Text as T
-- > default (T.Text)
module Shelly.Lifted
       (
         MonadSh(..),
         MonadShControl(..),

         -- This is copied from Shelly.hs, so that we are sure to export the
         -- exact same set of symbols.  Whenever that export list is updated,
         -- please make the same updates here and implements the corresponding
         -- lifted functions.

         -- * Entering Sh
         Sh, ShIO, S.shelly, S.shellyNoDir, S.shellyFailDir, sub
         , silently, verbosely, escaping, print_stdout, print_stderr, print_commands, print_commands_with
         , tracing, errExit
         , log_stdout_with, log_stderr_with

         -- * Running external commands
         , run, run_, runFoldLines, S.cmd, S.FoldCallback
         , (-|-), lastStderr, setStdin, lastExitCode
         , command, command_, command1, command1_
         , sshPairs, sshPairs_
         , S.ShellCmd(..), S.CmdArg (..)

         -- * Running commands Using handles
         , runHandle, runHandles, transferLinesAndCombine, S.transferFoldHandleLines
         , S.StdHandle(..), S.StdStream(..)


         -- * Modifying and querying environment
         , setenv, get_env, get_env_text, get_env_all, appendToPath, prependToPath

         -- * Environment directory
         , cd, chdir, chdir_p, pwd

         -- * Printing
         , echo, echo_n, echo_err, echo_n_err, echoWith, inspect, inspect_err
         , tag, trace, S.show_command

         -- * Querying filesystem
         , ls, lsT, test_e, test_f, test_d, test_s, test_px, which

         -- * Filename helpers
         , absPath, (S.</>), (S.<.>), canonic, canonicalize, relPath, relativeTo
         , S.hasExt

         -- * Manipulating filesystem
         , mv, rm, rm_f, rm_rf, cp, cp_r, mkdir, mkdir_p, mkdirTree

         -- * reading/writing Files
         , readfile, readBinary, writefile, appendfile, touchfile, withTmpDir

         -- * exiting the program
         , exit, errorExit, quietExit, terror

         -- * Exceptions
         , bracket_sh, catchany, catch_sh, handle_sh, handleany_sh, finally_sh, catches_sh, catchany_sh

         -- * convert between Text and FilePath
         , S.toTextIgnore, toTextWarn, S.fromText

         -- * Utility Functions
         , S.whenM, S.unlessM, time, sleep

         -- * Re-exported for your convenience
         , liftIO, S.when, S.unless, FilePath, (S.<$>)

         -- * internal functions for writing extensions
         , Shelly.Lifted.get, Shelly.Lifted.put

         -- * find functions
         , S.find, S.findWhen, S.findFold, S.findDirFilter, S.findDirFilterWhen, S.findFoldDirFilter
         , followSymlink
         ) where

import qualified Shelly      as S
import qualified Shelly.Base as S
import Shelly.Base     ( Sh(..), ShIO, Text, (>=>) )

import Control.Monad   ( liftM )
import Data.ByteString ( ByteString )
import Data.Tree       ( Tree )
import System.IO       ( Handle )

import Control.Exception.Lifted
import Control.Exception.Enclosed
import Control.Monad.IO.Class
import Control.Monad.Trans.Control
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Cont
import Control.Monad.Trans.Except
import Control.Monad.Trans.Reader
import Control.Monad.Trans.State
import qualified Control.Monad.Trans.State.Strict as Strict
import Control.Monad.Trans.Writer
import qualified Control.Monad.Trans.Writer.Strict as Strict
import qualified Control.Monad.Trans.RWS as RWS
import qualified Control.Monad.Trans.RWS.Strict as Strict

class Monad m => MonadSh m where
    liftSh :: Sh a -> m a

instance MonadSh Sh where
    liftSh :: forall a. Sh a -> Sh a
liftSh = Sh a -> Sh a
forall a. a -> a
id

instance MonadSh m => MonadSh (IdentityT m) where
    liftSh :: forall a. Sh a -> IdentityT m a
liftSh = m a -> IdentityT m a
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> (Sh a -> m a) -> Sh a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh

instance MonadSh m => MonadSh (MaybeT m) where
    liftSh :: forall a. Sh a -> MaybeT m a
liftSh = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a)
-> (Sh a -> m (Maybe a)) -> Sh a -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Maybe a) -> m a -> m (Maybe a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> Maybe a
forall a. a -> Maybe a
Just (m a -> m (Maybe a)) -> (Sh a -> m a) -> Sh a -> m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh

instance MonadSh m => MonadSh (ContT r m) where
    liftSh :: forall a. Sh a -> ContT r m a
liftSh Sh a
m = ((a -> m r) -> m r) -> ContT r m a
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m m a -> (a -> m r) -> m r
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=)

instance (MonadSh m) => MonadSh (ExceptT e m) where
    liftSh :: forall a. Sh a -> ExceptT e m a
liftSh Sh a
m = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        Either e a -> m (Either e a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Either e a
forall a b. b -> Either a b
Right a
a)

instance MonadSh m => MonadSh (ReaderT r m) where
    liftSh :: forall a. Sh a -> ReaderT r m a
liftSh = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a)
-> (Sh a -> r -> m a) -> Sh a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> r -> m a
forall a b. a -> b -> a
const (m a -> r -> m a) -> (Sh a -> m a) -> Sh a -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh

instance MonadSh m => MonadSh (StateT s m) where
    liftSh :: forall a. Sh a -> StateT s m a
liftSh Sh a
m = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, s) -> m (a, s)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, s
s)

instance MonadSh m => MonadSh (Strict.StateT s m) where
    liftSh :: forall a. Sh a -> StateT s m a
liftSh Sh a
m = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, s) -> m (a, s)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, s
s)

instance (Monoid w, MonadSh m) => MonadSh (WriterT w m) where
    liftSh :: forall a. Sh a -> WriterT w m a
liftSh Sh a
m = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, w) -> m (a, w)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, w
forall a. Monoid a => a
mempty :: w)

instance (Monoid w, MonadSh m) => MonadSh (Strict.WriterT w m) where
    liftSh :: forall a. Sh a -> WriterT w m a
liftSh Sh a
m = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, w) -> m (a, w)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, w
forall a. Monoid a => a
mempty :: w)

instance (Monoid w, MonadSh m) => MonadSh (RWS.RWST r w s m) where
    liftSh :: forall a. Sh a -> RWST r w s m a
liftSh Sh a
m = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
_ s
s -> do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, s, w) -> m (a, s, w)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, s
s, w
forall a. Monoid a => a
mempty :: w)

instance (Monoid w, MonadSh m) => MonadSh (Strict.RWST r w s m) where
    liftSh :: forall a. Sh a -> RWST r w s m a
liftSh Sh a
m = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
_ s
s -> do
        a
a <- Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh a
m
        (a, s, w) -> m (a, s, w)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, s
s, w
forall a. Monoid a => a
mempty :: w)

instance MonadSh m => S.ShellCmd (m Text) where
    cmdAll :: FilePath -> [Text] -> m Text
cmdAll = (Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> ([Text] -> Sh Text) -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([Text] -> Sh Text) -> [Text] -> m Text)
-> (FilePath -> [Text] -> Sh Text) -> FilePath -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [Text] -> Sh Text
S.run

instance (MonadSh m, s ~ Text, Show s) => S.ShellCmd (m s) where
    cmdAll :: FilePath -> [Text] -> m s
cmdAll = (Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> ([Text] -> Sh Text) -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([Text] -> Sh Text) -> [Text] -> m Text)
-> (FilePath -> [Text] -> Sh Text) -> FilePath -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [Text] -> Sh Text
S.run

instance MonadSh m => S.ShellCmd (m ()) where
    cmdAll :: FilePath -> [Text] -> m ()
cmdAll = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> ([Text] -> Sh ()) -> [Text] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([Text] -> Sh ()) -> [Text] -> m ())
-> (FilePath -> [Text] -> Sh ()) -> FilePath -> [Text] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [Text] -> Sh ()
S.run_

class Monad m => MonadShControl m where
    data ShM m a
    liftShWith :: ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
    restoreSh :: ShM m a -> m a

instance MonadShControl Sh where
     newtype ShM Sh a = ShSh a
     liftShWith :: forall a. ((forall x. Sh x -> Sh (ShM Sh x)) -> Sh a) -> Sh a
liftShWith (forall x. Sh x -> Sh (ShM Sh x)) -> Sh a
f = (forall x. Sh x -> Sh (ShM Sh x)) -> Sh a
f ((forall x. Sh x -> Sh (ShM Sh x)) -> Sh a)
-> (forall x. Sh x -> Sh (ShM Sh x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ (x -> ShM Sh x) -> Sh x -> Sh (ShM Sh x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM x -> ShM Sh x
forall a. a -> ShM Sh a
ShSh
     restoreSh :: forall a. ShM Sh a -> Sh a
restoreSh (ShSh a
x) = a -> Sh a
forall a. a -> Sh a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
     {-# INLINE liftShWith #-}
     {-# INLINE restoreSh #-}

instance MonadShControl m => MonadShControl (MaybeT m) where
    newtype ShM (MaybeT m) a = MaybeTShM (ShM m (Maybe a))
    liftShWith :: forall a.
((forall x. MaybeT m x -> Sh (ShM (MaybeT m) x)) -> Sh a)
-> MaybeT m a
liftShWith (forall x. MaybeT m x -> Sh (ShM (MaybeT m) x)) -> Sh a
f =
        m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ (a -> Maybe a) -> m a -> m (Maybe a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> Maybe a
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return (m a -> m (Maybe a)) -> m a -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. MaybeT m x -> Sh (ShM (MaybeT m) x)) -> Sh a
f ((forall x. MaybeT m x -> Sh (ShM (MaybeT m) x)) -> Sh a)
-> (forall x. MaybeT m x -> Sh (ShM (MaybeT m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \MaybeT m x
k ->
            (ShM m (Maybe x) -> ShM (MaybeT m) x)
-> Sh (ShM m (Maybe x)) -> Sh (ShM (MaybeT m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (Maybe x) -> ShM (MaybeT m) x
forall (m :: * -> *) a. ShM m (Maybe a) -> ShM (MaybeT m) a
MaybeTShM (Sh (ShM m (Maybe x)) -> Sh (ShM (MaybeT m) x))
-> Sh (ShM m (Maybe x)) -> Sh (ShM (MaybeT m) x)
forall a b. (a -> b) -> a -> b
$ m (Maybe x) -> Sh (ShM m (Maybe x))
forall x. m x -> Sh (ShM m x)
runInSh (m (Maybe x) -> Sh (ShM m (Maybe x)))
-> m (Maybe x) -> Sh (ShM m (Maybe x))
forall a b. (a -> b) -> a -> b
$ MaybeT m x -> m (Maybe x)
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT MaybeT m x
k
    restoreSh :: forall a. ShM (MaybeT m) a -> MaybeT m a
restoreSh (MaybeTShM ShM m (Maybe a)
m) = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a)
-> (ShM m (Maybe a) -> m (Maybe a))
-> ShM m (Maybe a)
-> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (Maybe a) -> m (Maybe a)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (Maybe a) -> MaybeT m a) -> ShM m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ ShM m (Maybe a)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance MonadShControl m
         => MonadShControl (IdentityT m) where
    newtype ShM (IdentityT m) a = IdentityTShM (ShM m a)
    liftShWith :: forall a.
((forall x. IdentityT m x -> Sh (ShM (IdentityT m) x)) -> Sh a)
-> IdentityT m a
liftShWith (forall x. IdentityT m x -> Sh (ShM (IdentityT m) x)) -> Sh a
f =
        m a -> IdentityT m a
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ (a -> a) -> m a -> m a
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> a
forall a. a -> a
id (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. IdentityT m x -> Sh (ShM (IdentityT m) x)) -> Sh a
f ((forall x. IdentityT m x -> Sh (ShM (IdentityT m) x)) -> Sh a)
-> (forall x. IdentityT m x -> Sh (ShM (IdentityT m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \IdentityT m x
k ->
            (ShM m x -> ShM (IdentityT m) x)
-> Sh (ShM m x) -> Sh (ShM (IdentityT m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m x -> ShM (IdentityT m) x
forall (m :: * -> *) a. ShM m a -> ShM (IdentityT m) a
IdentityTShM (Sh (ShM m x) -> Sh (ShM (IdentityT m) x))
-> Sh (ShM m x) -> Sh (ShM (IdentityT m) x)
forall a b. (a -> b) -> a -> b
$ m x -> Sh (ShM m x)
forall x. m x -> Sh (ShM m x)
runInSh (m x -> Sh (ShM m x)) -> m x -> Sh (ShM m x)
forall a b. (a -> b) -> a -> b
$ IdentityT m x -> m x
forall {k} (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT IdentityT m x
k
    restoreSh :: forall a. ShM (IdentityT m) a -> IdentityT m a
restoreSh (IdentityTShM ShM m a
m) = m a -> IdentityT m a
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a)
-> (ShM m a -> m a) -> ShM m a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m a -> m a
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m a -> IdentityT m a) -> ShM m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ ShM m a
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance (MonadShControl m, Monoid w)
         => MonadShControl (WriterT w m) where
    newtype ShM (WriterT w m) a = WriterTShM (ShM m (a, w))
    liftShWith :: forall a.
((forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a)
-> WriterT w m a
liftShWith (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
f =
        m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a -> (a, w)) -> m a -> m (a, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM  (\a
x -> (a
x, w
forall a. Monoid a => a
mempty :: w)) (m a -> m (a, w)) -> m a -> m (a, w)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
f ((forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a)
-> (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \WriterT w m x
k ->
            (ShM m (x, w) -> ShM (WriterT w m) x)
-> Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, w) -> ShM (WriterT w m) x
forall w (m :: * -> *) a. ShM m (a, w) -> ShM (WriterT w m) a
WriterTShM (Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x))
-> Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x)
forall a b. (a -> b) -> a -> b
$ m (x, w) -> Sh (ShM m (x, w))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, w) -> Sh (ShM m (x, w))) -> m (x, w) -> Sh (ShM m (x, w))
forall a b. (a -> b) -> a -> b
$ WriterT w m x -> m (x, w)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT WriterT w m x
k
    restoreSh :: forall a. ShM (WriterT w m) a -> WriterT w m a
restoreSh (WriterTShM ShM m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterT (m (a, w) -> WriterT w m a)
-> (ShM m (a, w) -> m (a, w)) -> ShM m (a, w) -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, w) -> m (a, w)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, w) -> WriterT w m a) -> ShM m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, w)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance (MonadShControl m, Monoid w)
         => MonadShControl (Strict.WriterT w m) where
    newtype ShM (Strict.WriterT w m) a = StWriterTShM (ShM m (a, w))
    liftShWith :: forall a.
((forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a)
-> WriterT w m a
liftShWith (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
f =
        m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a -> (a, w)) -> m a -> m (a, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\a
x -> (a
x, w
forall a. Monoid a => a
mempty :: w)) (m a -> m (a, w)) -> m a -> m (a, w)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
f ((forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a)
-> (forall x. WriterT w m x -> Sh (ShM (WriterT w m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \WriterT w m x
k ->
            (ShM m (x, w) -> ShM (WriterT w m) x)
-> Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, w) -> ShM (WriterT w m) x
forall w (m :: * -> *) a. ShM m (a, w) -> ShM (WriterT w m) a
StWriterTShM (Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x))
-> Sh (ShM m (x, w)) -> Sh (ShM (WriterT w m) x)
forall a b. (a -> b) -> a -> b
$ m (x, w) -> Sh (ShM m (x, w))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, w) -> Sh (ShM m (x, w))) -> m (x, w) -> Sh (ShM m (x, w))
forall a b. (a -> b) -> a -> b
$ WriterT w m x -> m (x, w)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT WriterT w m x
k
    restoreSh :: forall a. ShM (WriterT w m) a -> WriterT w m a
restoreSh (StWriterTShM ShM m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w) -> WriterT w m a)
-> (ShM m (a, w) -> m (a, w)) -> ShM m (a, w) -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, w) -> m (a, w)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, w) -> WriterT w m a) -> ShM m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, w)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance MonadShControl m => MonadShControl (ExceptT e m) where
    newtype ShM (ExceptT e m) a = ExceptTShM (ShM m (Either e a))
    liftShWith :: forall a.
((forall x. ExceptT e m x -> Sh (ShM (ExceptT e m) x)) -> Sh a)
-> ExceptT e m a
liftShWith (forall x. ExceptT e m x -> Sh (ShM (ExceptT e m) x)) -> Sh a
f =
        m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ (a -> Either e a) -> m a -> m (Either e a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> Either e a
forall a. a -> Either e a
forall (m :: * -> *) a. Monad m => a -> m a
return (m a -> m (Either e a)) -> m a -> m (Either e a)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. ExceptT e m x -> Sh (ShM (ExceptT e m) x)) -> Sh a
f ((forall x. ExceptT e m x -> Sh (ShM (ExceptT e m) x)) -> Sh a)
-> (forall x. ExceptT e m x -> Sh (ShM (ExceptT e m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \ExceptT e m x
k ->
            (ShM m (Either e x) -> ShM (ExceptT e m) x)
-> Sh (ShM m (Either e x)) -> Sh (ShM (ExceptT e m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (Either e x) -> ShM (ExceptT e m) x
forall e (m :: * -> *) a. ShM m (Either e a) -> ShM (ExceptT e m) a
ExceptTShM (Sh (ShM m (Either e x)) -> Sh (ShM (ExceptT e m) x))
-> Sh (ShM m (Either e x)) -> Sh (ShM (ExceptT e m) x)
forall a b. (a -> b) -> a -> b
$ m (Either e x) -> Sh (ShM m (Either e x))
forall x. m x -> Sh (ShM m x)
runInSh (m (Either e x) -> Sh (ShM m (Either e x)))
-> m (Either e x) -> Sh (ShM m (Either e x))
forall a b. (a -> b) -> a -> b
$ ExceptT e m x -> m (Either e x)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT ExceptT e m x
k
    restoreSh :: forall a. ShM (ExceptT e m) a -> ExceptT e m a
restoreSh (ExceptTShM ShM m (Either e a)
m) = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> (ShM m (Either e a) -> m (Either e a))
-> ShM m (Either e a)
-> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (Either e a) -> m (Either e a)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (Either e a) -> ExceptT e m a)
-> ShM m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ ShM m (Either e a)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance MonadShControl m => MonadShControl (StateT s m) where
    newtype ShM (StateT s m) a = StateTShM (ShM m (a, s))
    liftShWith :: forall a.
((forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a)
-> StateT s m a
liftShWith (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
f = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s ->
        (a -> (a, s)) -> m a -> m (a, s)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\a
x -> (a
x,s
s)) (m a -> m (a, s)) -> m a -> m (a, s)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
f ((forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a)
-> (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \StateT s m x
k ->
            (ShM m (x, s) -> ShM (StateT s m) x)
-> Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, s) -> ShM (StateT s m) x
forall s (m :: * -> *) a. ShM m (a, s) -> ShM (StateT s m) a
StateTShM (Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x))
-> Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x)
forall a b. (a -> b) -> a -> b
$ m (x, s) -> Sh (ShM m (x, s))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, s) -> Sh (ShM m (x, s))) -> m (x, s) -> Sh (ShM m (x, s))
forall a b. (a -> b) -> a -> b
$ StateT s m x -> s -> m (x, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT s m x
k s
s
    restoreSh :: forall a. ShM (StateT s m) a -> StateT s m a
restoreSh (StateTShM ShM m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((s -> m (a, s)) -> StateT s m a)
-> (ShM m (a, s) -> s -> m (a, s)) -> ShM m (a, s) -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (a, s) -> s -> m (a, s)
forall a b. a -> b -> a
const (m (a, s) -> s -> m (a, s))
-> (ShM m (a, s) -> m (a, s)) -> ShM m (a, s) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, s) -> m (a, s)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, s) -> StateT s m a) -> ShM m (a, s) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, s)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance MonadShControl m => MonadShControl (Strict.StateT s m) where
    newtype ShM (Strict.StateT s m) a = StStateTShM (ShM m (a, s))
    liftShWith :: forall a.
((forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a)
-> StateT s m a
liftShWith (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
f = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s ->
        (a -> (a, s)) -> m a -> m (a, s)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\a
x -> (a
x,s
s)) (m a -> m (a, s)) -> m a -> m (a, s)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
f ((forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a)
-> (forall x. StateT s m x -> Sh (ShM (StateT s m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \StateT s m x
k ->
            (ShM m (x, s) -> ShM (StateT s m) x)
-> Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, s) -> ShM (StateT s m) x
forall s (m :: * -> *) a. ShM m (a, s) -> ShM (StateT s m) a
StStateTShM (Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x))
-> Sh (ShM m (x, s)) -> Sh (ShM (StateT s m) x)
forall a b. (a -> b) -> a -> b
$ m (x, s) -> Sh (ShM m (x, s))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, s) -> Sh (ShM m (x, s))) -> m (x, s) -> Sh (ShM m (x, s))
forall a b. (a -> b) -> a -> b
$ StateT s m x -> s -> m (x, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT StateT s m x
k s
s
    restoreSh :: forall a. ShM (StateT s m) a -> StateT s m a
restoreSh (StStateTShM ShM m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (ShM m (a, s) -> s -> m (a, s)) -> ShM m (a, s) -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (a, s) -> s -> m (a, s)
forall a b. a -> b -> a
const (m (a, s) -> s -> m (a, s))
-> (ShM m (a, s) -> m (a, s)) -> ShM m (a, s) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, s) -> m (a, s)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, s) -> StateT s m a) -> ShM m (a, s) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, s)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance MonadShControl m => MonadShControl (ReaderT r m) where
    newtype ShM (ReaderT r m) a = ReaderTShM (ShM m a)
    liftShWith :: forall a.
((forall x. ReaderT r m x -> Sh (ShM (ReaderT r m) x)) -> Sh a)
-> ReaderT r m a
liftShWith (forall x. ReaderT r m x -> Sh (ShM (ReaderT r m) x)) -> Sh a
f = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ \r
r ->
        (a -> a) -> m a -> m a
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> a
forall a. a -> a
id (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. ReaderT r m x -> Sh (ShM (ReaderT r m) x)) -> Sh a
f ((forall x. ReaderT r m x -> Sh (ShM (ReaderT r m) x)) -> Sh a)
-> (forall x. ReaderT r m x -> Sh (ShM (ReaderT r m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \ReaderT r m x
k ->
            (ShM m x -> ShM (ReaderT r m) x)
-> Sh (ShM m x) -> Sh (ShM (ReaderT r m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m x -> ShM (ReaderT r m) x
forall r (m :: * -> *) a. ShM m a -> ShM (ReaderT r m) a
ReaderTShM (Sh (ShM m x) -> Sh (ShM (ReaderT r m) x))
-> Sh (ShM m x) -> Sh (ShM (ReaderT r m) x)
forall a b. (a -> b) -> a -> b
$ m x -> Sh (ShM m x)
forall x. m x -> Sh (ShM m x)
runInSh (m x -> Sh (ShM m x)) -> m x -> Sh (ShM m x)
forall a b. (a -> b) -> a -> b
$ ReaderT r m x -> r -> m x
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT r m x
k r
r
    restoreSh :: forall a. ShM (ReaderT r m) a -> ReaderT r m a
restoreSh (ReaderTShM ShM m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a)
-> (ShM m a -> r -> m a) -> ShM m a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> r -> m a
forall a b. a -> b -> a
const (m a -> r -> m a) -> (ShM m a -> m a) -> ShM m a -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m a -> m a
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m a -> ReaderT r m a) -> ShM m a -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ ShM m a
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance (MonadShControl m, Monoid w)
         => MonadShControl (RWS.RWST r w s m) where
    newtype ShM (RWS.RWST r w s m) a = RWSTShM (ShM m (a, s ,w))
    liftShWith :: forall a.
((forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a)
-> RWST r w s m a
liftShWith (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
f = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
        (a -> (a, s, w)) -> m a -> m (a, s, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\a
x -> (a
x,s
s,w
forall a. Monoid a => a
mempty :: w)) (m a -> m (a, s, w)) -> m a -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
f ((forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a)
-> (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \RWST r w s m x
k ->
            (ShM m (x, s, w) -> ShM (RWST r w s m) x)
-> Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, s, w) -> ShM (RWST r w s m) x
forall r w s (m :: * -> *) a.
ShM m (a, s, w) -> ShM (RWST r w s m) a
RWSTShM (Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x))
-> Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x)
forall a b. (a -> b) -> a -> b
$ m (x, s, w) -> Sh (ShM m (x, s, w))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, s, w) -> Sh (ShM m (x, s, w)))
-> m (x, s, w) -> Sh (ShM m (x, s, w))
forall a b. (a -> b) -> a -> b
$ RWST r w s m x -> r -> s -> m (x, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
RWS.runRWST RWST r w s m x
k r
r s
s
    restoreSh :: forall a. ShM (RWST r w s m) a -> RWST r w s m a
restoreSh (RWSTShM ShM m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (ShM m (a, s, w) -> r -> s -> m (a, s, w))
-> ShM m (a, s, w)
-> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> m (a, s, w)) -> r -> s -> m (a, s, w)
forall a b. a -> b -> a
const ((s -> m (a, s, w)) -> r -> s -> m (a, s, w))
-> (ShM m (a, s, w) -> s -> m (a, s, w))
-> ShM m (a, s, w)
-> r
-> s
-> m (a, s, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (a, s, w) -> s -> m (a, s, w)
forall a b. a -> b -> a
const (m (a, s, w) -> s -> m (a, s, w))
-> (ShM m (a, s, w) -> m (a, s, w))
-> ShM m (a, s, w)
-> s
-> m (a, s, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, s, w) -> m (a, s, w)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, s, w) -> RWST r w s m a)
-> ShM m (a, s, w) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, s, w)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

instance (MonadShControl m, Monoid w)
         => MonadShControl (Strict.RWST r w s m) where
    newtype ShM (Strict.RWST r w s m) a = StRWSTShM (ShM m (a, s, w))
    liftShWith :: forall a.
((forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a)
-> RWST r w s m a
liftShWith (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
f = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
        (a -> (a, s, w)) -> m a -> m (a, s, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\a
x -> (a
x,s
s,w
forall a. Monoid a => a
mempty :: w)) (m a -> m (a, s, w)) -> m a -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a. ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
f ((forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a)
-> (forall x. RWST r w s m x -> Sh (ShM (RWST r w s m) x)) -> Sh a
forall a b. (a -> b) -> a -> b
$ \RWST r w s m x
k ->
            (ShM m (x, s, w) -> ShM (RWST r w s m) x)
-> Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ShM m (x, s, w) -> ShM (RWST r w s m) x
forall r w s (m :: * -> *) a.
ShM m (a, s, w) -> ShM (RWST r w s m) a
StRWSTShM (Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x))
-> Sh (ShM m (x, s, w)) -> Sh (ShM (RWST r w s m) x)
forall a b. (a -> b) -> a -> b
$ m (x, s, w) -> Sh (ShM m (x, s, w))
forall x. m x -> Sh (ShM m x)
runInSh (m (x, s, w) -> Sh (ShM m (x, s, w)))
-> m (x, s, w) -> Sh (ShM m (x, s, w))
forall a b. (a -> b) -> a -> b
$ RWST r w s m x -> r -> s -> m (x, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST RWST r w s m x
k r
r s
s
    restoreSh :: forall a. ShM (RWST r w s m) a -> RWST r w s m a
restoreSh (StRWSTShM ShM m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (ShM m (a, s, w) -> r -> s -> m (a, s, w))
-> ShM m (a, s, w)
-> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> m (a, s, w)) -> r -> s -> m (a, s, w)
forall a b. a -> b -> a
const ((s -> m (a, s, w)) -> r -> s -> m (a, s, w))
-> (ShM m (a, s, w) -> s -> m (a, s, w))
-> ShM m (a, s, w)
-> r
-> s
-> m (a, s, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (a, s, w) -> s -> m (a, s, w)
forall a b. a -> b -> a
const (m (a, s, w) -> s -> m (a, s, w))
-> (ShM m (a, s, w) -> m (a, s, w))
-> ShM m (a, s, w)
-> s
-> m (a, s, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShM m (a, s, w) -> m (a, s, w)
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh (ShM m (a, s, w) -> RWST r w s m a)
-> ShM m (a, s, w) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ ShM m (a, s, w)
m
    {-# INLINE liftShWith #-}
    {-# INLINE restoreSh #-}

controlSh :: MonadShControl m => ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh :: forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh = ((forall {x}. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m (ShM m a)
forall a. ((forall {x}. m x -> Sh (ShM m x)) -> Sh a) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh a) -> m a
liftShWith (((forall {x}. m x -> Sh (ShM m x)) -> Sh (ShM m a))
 -> m (ShM m a))
-> (ShM m a -> m a)
-> ((forall {x}. m x -> Sh (ShM m x)) -> Sh (ShM m a))
-> m a
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> ShM m a -> m a
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh
{-# INLINE controlSh #-}

tag :: (MonadShControl m, MonadSh m) => m a -> Text -> m a
tag :: forall (m :: * -> *) a.
(MonadShControl m, MonadSh m) =>
m a -> Text -> m a
tag m a
action Text
msg = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Sh (ShM m a) -> Text -> Sh (ShM m a)
forall a. Sh a -> Text -> Sh a
S.tag (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action) Text
msg

chdir :: MonadShControl m => FilePath -> m a -> m a
chdir :: forall (m :: * -> *) a. MonadShControl m => FilePath -> m a -> m a
chdir FilePath
dir m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> FilePath -> Sh (ShM m a) -> Sh (ShM m a)
forall a. FilePath -> Sh a -> Sh a
S.chdir FilePath
dir (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

chdir_p :: MonadShControl m => FilePath -> m a -> m a
chdir_p :: forall (m :: * -> *) a. MonadShControl m => FilePath -> m a -> m a
chdir_p FilePath
dir m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> FilePath -> Sh (ShM m a) -> Sh (ShM m a)
forall a. FilePath -> Sh a -> Sh a
S.chdir_p FilePath
dir (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

silently :: MonadShControl m => m a -> m a
silently :: forall (m :: * -> *) a. MonadShControl m => m a -> m a
silently m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Sh a -> Sh a
S.silently (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

verbosely :: MonadShControl m => m a -> m a
verbosely :: forall (m :: * -> *) a. MonadShControl m => m a -> m a
verbosely m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Sh a -> Sh a
S.verbosely (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

log_stdout_with :: MonadShControl m => (Text -> IO ()) -> m a -> m a
log_stdout_with :: forall (m :: * -> *) a.
MonadShControl m =>
(Text -> IO ()) -> m a -> m a
log_stdout_with Text -> IO ()
logger m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (Text -> IO ()) -> Sh (ShM m a) -> Sh (ShM m a)
forall a. (Text -> IO ()) -> Sh a -> Sh a
S.log_stdout_with Text -> IO ()
logger (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

log_stderr_with :: MonadShControl m => (Text -> IO ()) -> m a -> m a
log_stderr_with :: forall (m :: * -> *) a.
MonadShControl m =>
(Text -> IO ()) -> m a -> m a
log_stderr_with Text -> IO ()
logger m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (Text -> IO ()) -> Sh (ShM m a) -> Sh (ShM m a)
forall a. (Text -> IO ()) -> Sh a -> Sh a
S.log_stderr_with Text -> IO ()
logger (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

print_stdout :: MonadShControl m => Bool -> m a -> m a
print_stdout :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
print_stdout Bool
shouldPrint m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.print_stdout Bool
shouldPrint (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

print_stderr :: MonadShControl m => Bool -> m a -> m a
print_stderr :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
print_stderr Bool
shouldPrint m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.print_stderr Bool
shouldPrint (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

print_commands :: MonadShControl m => Bool -> m a -> m a
print_commands :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
print_commands Bool
shouldPrint m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.print_commands Bool
shouldPrint (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

-- | @since 1.12.1
print_commands_with :: MonadShControl m => (Text -> IO ()) -> m a -> m a
print_commands_with :: forall (m :: * -> *) a.
MonadShControl m =>
(Text -> IO ()) -> m a -> m a
print_commands_with Text -> IO ()
fn m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (Text -> IO ()) -> Sh (ShM m a) -> Sh (ShM m a)
forall a. (Text -> IO ()) -> Sh a -> Sh a
S.print_commands_with Text -> IO ()
fn (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

sub :: MonadShControl m => m a -> m a
sub :: forall (m :: * -> *) a. MonadShControl m => m a -> m a
sub m a
a = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Sh a -> Sh a
S.sub (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
a)

trace :: MonadSh m => Text -> m ()
trace :: forall (m :: * -> *). MonadSh m => Text -> m ()
trace = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.trace

tracing :: MonadShControl m => Bool -> m a -> m a
tracing :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
tracing Bool
shouldTrace m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.tracing Bool
shouldTrace (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

escaping :: MonadShControl m => Bool -> m a -> m a
escaping :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
escaping Bool
shouldEscape m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.escaping Bool
shouldEscape (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

errExit :: MonadShControl m => Bool -> m a -> m a
errExit :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
errExit Bool
shouldExit m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.errExit Bool
shouldExit (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

followSymlink :: MonadShControl m => Bool -> m a -> m a
followSymlink :: forall (m :: * -> *) a. MonadShControl m => Bool -> m a -> m a
followSymlink Bool
enableFollowSymlink m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> Bool -> Sh (ShM m a) -> Sh (ShM m a)
forall a. Bool -> Sh a -> Sh a
S.followSymlink Bool
enableFollowSymlink (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
action)

(-|-) :: (MonadShControl m, MonadSh m) => m Text -> m b -> m b
m Text
one -|- :: forall (m :: * -> *) b.
(MonadShControl m, MonadSh m) =>
m Text -> m b -> m b
-|- m b
two = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> do
    ShM m Text
x <- m Text -> Sh (ShM m Text)
forall x. m x -> Sh (ShM m x)
runInSh m Text
one
    m b -> Sh (ShM m b)
forall x. m x -> Sh (ShM m x)
runInSh (m b -> Sh (ShM m b)) -> m b -> Sh (ShM m b)
forall a b. (a -> b) -> a -> b
$ ShM m Text -> m Text
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh ShM m Text
x m Text -> (Text -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x' ->
        ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m b)) -> m b
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh' -> Text -> Sh Text
forall a. a -> Sh a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
x' Sh Text -> Sh (ShM m b) -> Sh (ShM m b)
forall b. Sh Text -> Sh b -> Sh b
S.-|- m b -> Sh (ShM m b)
forall x. m x -> Sh (ShM m x)
runInSh' m b
two

withTmpDir :: MonadShControl m => (FilePath -> m a) -> m a
withTmpDir :: forall (m :: * -> *) a.
MonadShControl m =>
(FilePath -> m a) -> m a
withTmpDir FilePath -> m a
action = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> (FilePath -> Sh (ShM m a)) -> Sh (ShM m a)
forall a. (FilePath -> Sh a) -> Sh a
S.withTmpDir ((m a -> Sh (ShM m a))
-> (FilePath -> m a) -> FilePath -> Sh (ShM m a)
forall a b. (a -> b) -> (FilePath -> a) -> FilePath -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh FilePath -> m a
action)

time :: MonadShControl m => m a -> m (Double, a)
time :: forall (m :: * -> *) a. MonadShControl m => m a -> m (Double, a)
time m a
what = ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m (Double, a)))
-> m (Double, a)
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m (Double, a)))
 -> m (Double, a))
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m (Double, a)))
-> m (Double, a)
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> do
    (Double
d, ShM m a
a) <- Sh (ShM m a) -> Sh (Double, ShM m a)
forall a. Sh a -> Sh (Double, a)
S.time (m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh m a
what)
    m (Double, a) -> Sh (ShM m (Double, a))
forall x. m x -> Sh (ShM m x)
runInSh (m (Double, a) -> Sh (ShM m (Double, a)))
-> m (Double, a) -> Sh (ShM m (Double, a))
forall a b. (a -> b) -> a -> b
$ ShM m a -> m a
forall a. ShM m a -> m a
forall (m :: * -> *) a. MonadShControl m => ShM m a -> m a
restoreSh ShM m a
a m a -> (a -> m (Double, a)) -> m (Double, a)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a
x -> (Double, a) -> m (Double, a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
d, a
x)

toTextWarn :: MonadSh m => FilePath -> m Text
toTextWarn :: forall (m :: * -> *). MonadSh m => FilePath -> m Text
toTextWarn = Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> (FilePath -> Sh Text) -> FilePath -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Text
forall (m :: * -> *). MonadSh m => FilePath -> m Text
toTextWarn

transferLinesAndCombine :: MonadIO m => Handle -> (Text -> IO ()) -> m Text
transferLinesAndCombine :: forall (m :: * -> *).
MonadIO m =>
Handle -> (Text -> IO ()) -> m Text
transferLinesAndCombine = (IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text)
-> ((Text -> IO ()) -> IO Text) -> (Text -> IO ()) -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (((Text -> IO ()) -> IO Text) -> (Text -> IO ()) -> m Text)
-> (Handle -> (Text -> IO ()) -> IO Text)
-> Handle
-> (Text -> IO ())
-> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> (Text -> IO ()) -> IO Text
S.transferLinesAndCombine

get :: MonadSh m => m S.State
get :: forall (m :: * -> *). MonadSh m => m State
get = Sh State -> m State
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh State
S.get

put :: MonadSh m => S.State -> m ()
put :: forall (m :: * -> *). MonadSh m => State -> m ()
put = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (State -> Sh ()) -> State -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. State -> Sh ()
S.put

catch_sh :: Exception e => Sh a -> (e -> Sh a) -> Sh a
catch_sh :: forall e a. Exception e => Sh a -> (e -> Sh a) -> Sh a
catch_sh = Sh a -> (e -> Sh a) -> Sh a
forall (m :: * -> *) e a.
(MonadBaseControl IO m, Exception e) =>
m a -> (e -> m a) -> m a
Control.Exception.Lifted.catch
{-# DEPRECATED catch_sh "use Control.Exception.Lifted.catch instead" #-}

handle_sh :: Exception e => (e -> Sh a) -> Sh a -> Sh a
handle_sh :: forall e a. Exception e => (e -> Sh a) -> Sh a -> Sh a
handle_sh = (e -> Sh a) -> Sh a -> Sh a
forall (m :: * -> *) e a.
(MonadBaseControl IO m, Exception e) =>
(e -> m a) -> m a -> m a
handle
{-# DEPRECATED handle_sh "use Control.Exception.Lifted.handle instead" #-}

finally_sh :: Sh a -> Sh b -> Sh a
finally_sh :: forall a b. Sh a -> Sh b -> Sh a
finally_sh = Sh a -> Sh b -> Sh a
forall (m :: * -> *) a b.
MonadBaseControl IO m =>
m a -> m b -> m a
finally
{-# DEPRECATED finally_sh "use Control.Exception.Lifted.finally instead" #-}

bracket_sh :: Sh a -> (a -> Sh b) -> (a -> Sh c) -> Sh c
bracket_sh :: forall a b c. Sh a -> (a -> Sh b) -> (a -> Sh c) -> Sh c
bracket_sh = Sh a -> (a -> Sh b) -> (a -> Sh c) -> Sh c
forall (m :: * -> *) a b c.
MonadBaseControl IO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket
{-# DEPRECATED bracket_sh "use Control.Exception.Lifted.bracket instead" #-}

catches_sh :: Sh a -> [Handler Sh a] -> Sh a
catches_sh :: forall a. Sh a -> [Handler Sh a] -> Sh a
catches_sh = Sh a -> [Handler Sh a] -> Sh a
forall (m :: * -> *) a.
MonadBaseControl IO m =>
m a -> [Handler m a] -> m a
catches
{-# DEPRECATED catches_sh "use Control.Exception.Lifted.catches instead" #-}

catchany_sh :: Sh a -> (SomeException -> Sh a) -> Sh a
catchany_sh :: forall a. Sh a -> (SomeException -> Sh a) -> Sh a
catchany_sh = Sh a -> (SomeException -> Sh a) -> Sh a
forall (m :: * -> *) a.
MonadBaseControl IO m =>
m a -> (SomeException -> m a) -> m a
catchAny
{-# DEPRECATED catchany_sh "use Control.Exception.Enclosed.catchAny instead" #-}

handleany_sh :: (SomeException -> Sh a) -> Sh a -> Sh a
handleany_sh :: forall a. (SomeException -> Sh a) -> Sh a -> Sh a
handleany_sh = (SomeException -> Sh a) -> Sh a -> Sh a
forall (m :: * -> *) a.
MonadBaseControl IO m =>
(SomeException -> m a) -> m a -> m a
handleAny
{-# DEPRECATED handleany_sh "use Control.Exception.Enclosed.handleAny instead" #-}

cd :: MonadSh m => FilePath -> m ()
cd :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
cd = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.cd

mv :: MonadSh m => FilePath -> FilePath -> m ()
mv :: forall (m :: * -> *). MonadSh m => FilePath -> FilePath -> m ()
mv = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((FilePath -> Sh ()) -> FilePath -> m ())
-> (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> FilePath -> Sh ()
S.mv

lsT :: MonadSh m => FilePath -> m [Text]
lsT :: forall (m :: * -> *). MonadSh m => FilePath -> m [Text]
lsT = Sh [Text] -> m [Text]
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh [Text] -> m [Text])
-> (FilePath -> Sh [Text]) -> FilePath -> m [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh [Text]
S.lsT

pwd :: MonadSh m => m FilePath
pwd :: forall (m :: * -> *). MonadSh m => m FilePath
pwd = Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh FilePath
S.pwd

exit :: MonadSh m => Int -> m a
exit :: forall (m :: * -> *) a. MonadSh m => Int -> m a
exit = Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh a -> m a) -> (Int -> Sh a) -> Int -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Sh a
forall a. Int -> Sh a
S.exit

errorExit :: MonadSh m => Text -> m a
errorExit :: forall (m :: * -> *) a. MonadSh m => Text -> m a
errorExit = Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh a -> m a) -> (Text -> Sh a) -> Text -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh a
forall a. Text -> Sh a
S.errorExit

quietExit :: MonadSh m => Int -> m a
quietExit :: forall (m :: * -> *) a. MonadSh m => Int -> m a
quietExit = Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh a -> m a) -> (Int -> Sh a) -> Int -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Sh a
forall a. Int -> Sh a
S.quietExit

terror :: MonadSh m => Text -> m a
terror :: forall (m :: * -> *) a. MonadSh m => Text -> m a
terror = Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh a -> m a) -> (Text -> Sh a) -> Text -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh a
forall a. Text -> Sh a
S.terror

mkdir :: MonadSh m => FilePath -> m ()
mkdir :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
mkdir = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.mkdir

mkdir_p :: MonadSh m => FilePath -> m ()
mkdir_p :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
mkdir_p = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.mkdir_p

mkdirTree :: MonadSh m => Tree FilePath -> m ()
mkdirTree :: forall (m :: * -> *). MonadSh m => Tree FilePath -> m ()
mkdirTree = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ())
-> (Tree FilePath -> Sh ()) -> Tree FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tree FilePath -> Sh ()
S.mkdirTree

which :: MonadSh m => FilePath -> m (Maybe FilePath)
which :: forall (m :: * -> *). MonadSh m => FilePath -> m (Maybe FilePath)
which = Sh (Maybe FilePath) -> m (Maybe FilePath)
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh (Maybe FilePath) -> m (Maybe FilePath))
-> (FilePath -> Sh (Maybe FilePath))
-> FilePath
-> m (Maybe FilePath)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh (Maybe FilePath)
S.which

test_e :: MonadSh m => FilePath -> m Bool
test_e :: forall (m :: * -> *). MonadSh m => FilePath -> m Bool
test_e = Sh Bool -> m Bool
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Bool -> m Bool) -> (FilePath -> Sh Bool) -> FilePath -> m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
S.test_e

test_f :: MonadSh m => FilePath -> m Bool
test_f :: forall (m :: * -> *). MonadSh m => FilePath -> m Bool
test_f = Sh Bool -> m Bool
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Bool -> m Bool) -> (FilePath -> Sh Bool) -> FilePath -> m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
S.test_f

test_px :: MonadSh m => FilePath -> m Bool
test_px :: forall (m :: * -> *). MonadSh m => FilePath -> m Bool
test_px = Sh Bool -> m Bool
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Bool -> m Bool) -> (FilePath -> Sh Bool) -> FilePath -> m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
S.test_px

rm_rf :: MonadSh m => FilePath -> m ()
rm_rf :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
rm_rf = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.rm_rf

rm_f :: MonadSh m => FilePath -> m ()
rm_f :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
rm_f = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.rm_f

rm :: MonadSh m => FilePath -> m ()
rm :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
rm = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.rm

setenv :: MonadSh m => Text -> Text -> m ()
setenv :: forall (m :: * -> *). MonadSh m => Text -> Text -> m ()
setenv = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((Text -> Sh ()) -> Text -> m ())
-> (Text -> Text -> Sh ()) -> Text -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> Sh ()
S.setenv

appendToPath :: MonadSh m => FilePath -> m ()
appendToPath :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
appendToPath = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.appendToPath

prependToPath :: MonadSh m => FilePath -> m ()
prependToPath :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
prependToPath = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.prependToPath

get_env_all :: MonadSh m => m [(String, String)]
get_env_all :: forall (m :: * -> *). MonadSh m => m [(FilePath, FilePath)]
get_env_all = Sh [(FilePath, FilePath)] -> m [(FilePath, FilePath)]
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh [(FilePath, FilePath)]
S.get_env_all

get_env :: MonadSh m => Text -> m (Maybe Text)
get_env :: forall (m :: * -> *). MonadSh m => Text -> m (Maybe Text)
get_env = Sh (Maybe Text) -> m (Maybe Text)
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh (Maybe Text) -> m (Maybe Text))
-> (Text -> Sh (Maybe Text)) -> Text -> m (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh (Maybe Text)
S.get_env

get_env_text :: MonadSh m => Text -> m Text
get_env_text :: forall (m :: * -> *). MonadSh m => Text -> m Text
get_env_text = Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> (Text -> Sh Text) -> Text -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh Text
S.get_env_text

sshPairs_ :: MonadSh m => Text -> [(FilePath, [Text])] -> m ()
sshPairs_ :: forall (m :: * -> *).
MonadSh m =>
Text -> [(FilePath, [Text])] -> m ()
sshPairs_ = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ())
-> ([(FilePath, [Text])] -> Sh ()) -> [(FilePath, [Text])] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([(FilePath, [Text])] -> Sh ()) -> [(FilePath, [Text])] -> m ())
-> (Text -> [(FilePath, [Text])] -> Sh ())
-> Text
-> [(FilePath, [Text])]
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [(FilePath, [Text])] -> Sh ()
S.sshPairs_

sshPairs :: MonadSh m => Text -> [(FilePath, [Text])] -> m Text
sshPairs :: forall (m :: * -> *).
MonadSh m =>
Text -> [(FilePath, [Text])] -> m Text
sshPairs = (Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text)
-> ([(FilePath, [Text])] -> Sh Text)
-> [(FilePath, [Text])]
-> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([(FilePath, [Text])] -> Sh Text)
 -> [(FilePath, [Text])] -> m Text)
-> (Text -> [(FilePath, [Text])] -> Sh Text)
-> Text
-> [(FilePath, [Text])]
-> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [(FilePath, [Text])] -> Sh Text
S.sshPairs

run :: MonadSh m => FilePath -> [Text] -> m Text
run :: forall (m :: * -> *). MonadSh m => FilePath -> [Text] -> m Text
run = (Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> ([Text] -> Sh Text) -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([Text] -> Sh Text) -> [Text] -> m Text)
-> (FilePath -> [Text] -> Sh Text) -> FilePath -> [Text] -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [Text] -> Sh Text
S.run

command :: MonadSh m => FilePath -> [Text] -> [Text] -> m Text
command :: forall (m :: * -> *).
MonadSh m =>
FilePath -> [Text] -> [Text] -> m Text
command FilePath
com [Text]
args [Text]
more_args =
    Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> Sh Text -> m Text
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> [Text] -> Sh Text
S.command FilePath
com [Text]
args [Text]
more_args

command_ :: MonadSh m => FilePath -> [Text] -> [Text] -> m ()
command_ :: forall (m :: * -> *).
MonadSh m =>
FilePath -> [Text] -> [Text] -> m ()
command_ FilePath
com [Text]
args [Text]
more_args =
    Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> Sh () -> m ()
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> [Text] -> Sh ()
S.command_ FilePath
com [Text]
args [Text]
more_args

command1 :: MonadSh m => FilePath -> [Text] -> Text -> [Text] -> m Text
command1 :: forall (m :: * -> *).
MonadSh m =>
FilePath -> [Text] -> Text -> [Text] -> m Text
command1 FilePath
com [Text]
args Text
one_arg [Text]
more_args =
    Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> Sh Text -> m Text
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> Text -> [Text] -> Sh Text
S.command1 FilePath
com [Text]
args Text
one_arg [Text]
more_args

command1_ :: MonadSh m => FilePath -> [Text] -> Text -> [Text] -> m ()
command1_ :: forall (m :: * -> *).
MonadSh m =>
FilePath -> [Text] -> Text -> [Text] -> m ()
command1_ FilePath
com [Text]
args Text
one_arg [Text]
more_args =
    Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> Sh () -> m ()
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> Text -> [Text] -> Sh ()
S.command1_ FilePath
com [Text]
args Text
one_arg [Text]
more_args

run_ :: MonadSh m => FilePath -> [Text] -> m ()
run_ :: forall (m :: * -> *). MonadSh m => FilePath -> [Text] -> m ()
run_ = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> ([Text] -> Sh ()) -> [Text] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (([Text] -> Sh ()) -> [Text] -> m ())
-> (FilePath -> [Text] -> Sh ()) -> FilePath -> [Text] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [Text] -> Sh ()
S.run_

runHandle :: MonadShControl m => FilePath -- ^ command
          -> [Text] -- ^ arguments
          -> (Handle -> m a) -- ^ stdout handle
          -> m a
runHandle :: forall (m :: * -> *) a.
MonadShControl m =>
FilePath -> [Text] -> (Handle -> m a) -> m a
runHandle FilePath
exe [Text]
args Handle -> m a
withHandle =
    ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh -> FilePath -> [Text] -> (Handle -> Sh (ShM m a)) -> Sh (ShM m a)
forall a. FilePath -> [Text] -> (Handle -> Sh a) -> Sh a
S.runHandle FilePath
exe [Text]
args ((m a -> Sh (ShM m a)) -> (Handle -> m a) -> Handle -> Sh (ShM m a)
forall a b. (a -> b) -> (Handle -> a) -> Handle -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh Handle -> m a
withHandle)

runHandles :: MonadShControl m => FilePath -- ^ command
           -> [Text] -- ^ arguments
           -> [S.StdHandle] -- ^ optionally connect process i/o handles to existing handles
           -> (Handle -> Handle -> Handle -> m a) -- ^ stdin, stdout and stderr
           -> m a
runHandles :: forall (m :: * -> *) a.
MonadShControl m =>
FilePath
-> [Text]
-> [StdHandle]
-> (Handle -> Handle -> Handle -> m a)
-> m a
runHandles FilePath
exe [Text]
args [StdHandle]
reusedHandles Handle -> Handle -> Handle -> m a
withHandles =
    ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall (m :: * -> *) a.
MonadShControl m =>
((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
controlSh (((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a)
-> ((forall x. m x -> Sh (ShM m x)) -> Sh (ShM m a)) -> m a
forall a b. (a -> b) -> a -> b
$ \forall x. m x -> Sh (ShM m x)
runInSh ->
        FilePath
-> [Text]
-> [StdHandle]
-> (Handle -> Handle -> Handle -> Sh (ShM m a))
-> Sh (ShM m a)
forall a.
FilePath
-> [Text]
-> [StdHandle]
-> (Handle -> Handle -> Handle -> Sh a)
-> Sh a
S.runHandles FilePath
exe [Text]
args [StdHandle]
reusedHandles (((Handle -> Handle -> m a) -> Handle -> Handle -> Sh (ShM m a))
-> (Handle -> Handle -> Handle -> m a)
-> Handle
-> Handle
-> Handle
-> Sh (ShM m a)
forall a b. (a -> b) -> (Handle -> a) -> Handle -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Handle -> m a) -> Handle -> Sh (ShM m a))
-> (Handle -> Handle -> m a) -> Handle -> Handle -> Sh (ShM m a)
forall a b. (a -> b) -> (Handle -> a) -> Handle -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((m a -> Sh (ShM m a)) -> (Handle -> m a) -> Handle -> Sh (ShM m a)
forall a b. (a -> b) -> (Handle -> a) -> Handle -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap m a -> Sh (ShM m a)
forall x. m x -> Sh (ShM m x)
runInSh)) Handle -> Handle -> Handle -> m a
withHandles)

runFoldLines :: MonadSh m => a -> S.FoldCallback a -> FilePath -> [Text] -> m a
runFoldLines :: forall (m :: * -> *) a.
MonadSh m =>
a -> FoldCallback a -> FilePath -> [Text] -> m a
runFoldLines a
start FoldCallback a
cb FilePath
exe [Text]
args = Sh a -> m a
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh a -> m a) -> Sh a -> m a
forall a b. (a -> b) -> a -> b
$ a -> FoldCallback a -> FilePath -> [Text] -> Sh a
forall a. a -> FoldCallback a -> FilePath -> [Text] -> Sh a
S.runFoldLines a
start FoldCallback a
cb FilePath
exe [Text]
args

lastStderr :: MonadSh m => m Text
lastStderr :: forall (m :: * -> *). MonadSh m => m Text
lastStderr = Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh Text
S.lastStderr

lastExitCode :: MonadSh m => m Int
lastExitCode :: forall (m :: * -> *). MonadSh m => m Int
lastExitCode = Sh Int -> m Int
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh Sh Int
S.lastExitCode

setStdin :: MonadSh m => Text -> m ()
setStdin :: forall (m :: * -> *). MonadSh m => Text -> m ()
setStdin = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.setStdin

cp_r :: MonadSh m => FilePath -> FilePath -> m ()
cp_r :: forall (m :: * -> *). MonadSh m => FilePath -> FilePath -> m ()
cp_r = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((FilePath -> Sh ()) -> FilePath -> m ())
-> (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> FilePath -> Sh ()
S.cp_r

cp :: MonadSh m => FilePath -> FilePath -> m ()
cp :: forall (m :: * -> *). MonadSh m => FilePath -> FilePath -> m ()
cp = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((FilePath -> Sh ()) -> FilePath -> m ())
-> (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> FilePath -> Sh ()
S.cp

writefile :: MonadSh m => FilePath -> Text -> m ()
writefile :: forall (m :: * -> *). MonadSh m => FilePath -> Text -> m ()
writefile = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((Text -> Sh ()) -> Text -> m ())
-> (FilePath -> Text -> Sh ()) -> FilePath -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Text -> Sh ()
S.writefile

touchfile :: MonadSh m => FilePath -> m ()
touchfile :: forall (m :: * -> *). MonadSh m => FilePath -> m ()
touchfile = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (FilePath -> Sh ()) -> FilePath -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ()
S.touchfile

appendfile :: MonadSh m => FilePath -> Text -> m ()
appendfile :: forall (m :: * -> *). MonadSh m => FilePath -> Text -> m ()
appendfile = (Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((Text -> Sh ()) -> Text -> m ())
-> (FilePath -> Text -> Sh ()) -> FilePath -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Text -> Sh ()
S.appendfile

readfile :: MonadSh m => FilePath -> m Text
readfile :: forall (m :: * -> *). MonadSh m => FilePath -> m Text
readfile = Sh Text -> m Text
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Text -> m Text) -> (FilePath -> Sh Text) -> FilePath -> m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Text
S.readfile

readBinary :: MonadSh m => FilePath -> m ByteString
readBinary :: forall (m :: * -> *). MonadSh m => FilePath -> m ByteString
readBinary = Sh ByteString -> m ByteString
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh ByteString -> m ByteString)
-> (FilePath -> Sh ByteString) -> FilePath -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh ByteString
S.readBinary

sleep :: MonadSh m => Int -> m ()
sleep :: forall (m :: * -> *). MonadSh m => Int -> m ()
sleep = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Int -> Sh ()) -> Int -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Sh ()
S.sleep

echo, echo_n, echo_err, echo_n_err :: MonadSh m => Text -> m ()
echo :: forall (m :: * -> *). MonadSh m => Text -> m ()
echo       = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.echo
echo_n :: forall (m :: * -> *). MonadSh m => Text -> m ()
echo_n     = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.echo_n
echo_err :: forall (m :: * -> *). MonadSh m => Text -> m ()
echo_err   = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.echo_err
echo_n_err :: forall (m :: * -> *). MonadSh m => Text -> m ()
echo_n_err = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (Text -> Sh ()) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Sh ()
S.echo_n_err

-- | @since 1.12.1
echoWith :: MonadSh m => (Text -> IO ()) -> Text -> m ()
echoWith :: forall (m :: * -> *). MonadSh m => (Text -> IO ()) -> Text -> m ()
echoWith Text -> IO ()
f Text
msg = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> Sh () -> m ()
forall a b. (a -> b) -> a -> b
$ (Text -> IO ()) -> Text -> Sh ()
S.echoWith Text -> IO ()
f Text
msg

relPath :: MonadSh m => FilePath -> m FilePath
relPath :: forall (m :: * -> *). MonadSh m => FilePath -> m FilePath
relPath = Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh FilePath -> m FilePath)
-> (FilePath -> Sh FilePath) -> FilePath -> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh FilePath
S.relPath

relativeTo :: MonadSh m => FilePath -- ^ anchor path, the prefix
           -> FilePath -- ^ make this relative to anchor path
           -> m FilePath
relativeTo :: forall (m :: * -> *).
MonadSh m =>
FilePath -> FilePath -> m FilePath
relativeTo = (Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh FilePath -> m FilePath)
-> (FilePath -> Sh FilePath) -> FilePath -> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((FilePath -> Sh FilePath) -> FilePath -> m FilePath)
-> (FilePath -> FilePath -> Sh FilePath)
-> FilePath
-> FilePath
-> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> FilePath -> Sh FilePath
S.relativeTo

canonic :: MonadSh m => FilePath -> m FilePath
canonic :: forall (m :: * -> *). MonadSh m => FilePath -> m FilePath
canonic = Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh FilePath -> m FilePath)
-> (FilePath -> Sh FilePath) -> FilePath -> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh FilePath
forall (m :: * -> *). MonadSh m => FilePath -> m FilePath
canonic

-- | Obtain a (reasonably) canonic file path to a filesystem object. Based on
-- "canonicalizePath".
canonicalize :: MonadSh m => FilePath -> m FilePath
canonicalize :: forall (m :: * -> *). MonadSh m => FilePath -> m FilePath
canonicalize = Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh FilePath -> m FilePath)
-> (FilePath -> Sh FilePath) -> FilePath -> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh FilePath
S.canonicalize

absPath :: MonadSh m => FilePath -> m FilePath
absPath :: forall (m :: * -> *). MonadSh m => FilePath -> m FilePath
absPath = Sh FilePath -> m FilePath
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh FilePath -> m FilePath)
-> (FilePath -> Sh FilePath) -> FilePath -> m FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh FilePath
S.absPath

test_d :: MonadSh m => FilePath -> m Bool
test_d :: forall (m :: * -> *). MonadSh m => FilePath -> m Bool
test_d = Sh Bool -> m Bool
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Bool -> m Bool) -> (FilePath -> Sh Bool) -> FilePath -> m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
S.test_d

test_s :: MonadSh m => FilePath -> m Bool
test_s :: forall (m :: * -> *). MonadSh m => FilePath -> m Bool
test_s = Sh Bool -> m Bool
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh Bool -> m Bool) -> (FilePath -> Sh Bool) -> FilePath -> m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
S.test_s

ls :: MonadSh m => FilePath -> m [FilePath]
ls :: forall (m :: * -> *). MonadSh m => FilePath -> m [FilePath]
ls = Sh [FilePath] -> m [FilePath]
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh [FilePath] -> m [FilePath])
-> (FilePath -> Sh [FilePath]) -> FilePath -> m [FilePath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh [FilePath]
S.ls

inspect :: (Show s, MonadSh m) => s -> m ()
inspect :: forall s (m :: * -> *). (Show s, MonadSh m) => s -> m ()
inspect = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (s -> Sh ()) -> s -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> Sh ()
forall s. Show s => s -> Sh ()
S.inspect

inspect_err :: (Show s, MonadSh m) => s -> m ()
inspect_err :: forall s (m :: * -> *). (Show s, MonadSh m) => s -> m ()
inspect_err = Sh () -> m ()
forall a. Sh a -> m a
forall (m :: * -> *) a. MonadSh m => Sh a -> m a
liftSh (Sh () -> m ()) -> (s -> Sh ()) -> s -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> Sh ()
forall s. Show s => s -> Sh ()
S.inspect_err

catchany :: MonadBaseControl IO m => m a -> (SomeException -> m a) -> m a
catchany :: forall (m :: * -> *) a.
MonadBaseControl IO m =>
m a -> (SomeException -> m a) -> m a
catchany = m a -> (SomeException -> m a) -> m a
forall (m :: * -> *) e a.
(MonadBaseControl IO m, Exception e) =>
m a -> (e -> m a) -> m a
Control.Exception.Lifted.catch