module GitHub.Workflow.Command.Execution
( MonadCommand (..)
, PrintCommands (..)
) where
import Control.Applicative (Applicative)
import Control.Monad (Monad)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Function ((.))
import Data.Functor (Functor)
import GitHub.Workflow.Command.Syntax
import System.IO (IO)
class Monad m => MonadCommand m where
executeCommand :: ToCommand a => a -> m ()
instance MonadCommand IO where
executeCommand :: forall a. ToCommand a => a -> IO ()
executeCommand = Command -> IO ()
forall a (m :: * -> *). (ToByteString a, MonadIO m) => a -> m ()
printByteStringLn (Command -> IO ()) -> (a -> Command) -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Command
forall a. ToCommand a => a -> Command
toCommand
newtype PrintCommands m a = PrintCommands (m a)
deriving newtype ((forall a b. (a -> b) -> PrintCommands m a -> PrintCommands m b)
-> (forall a b. a -> PrintCommands m b -> PrintCommands m a)
-> Functor (PrintCommands m)
forall a b. a -> PrintCommands m b -> PrintCommands m a
forall a b. (a -> b) -> PrintCommands m a -> PrintCommands m b
forall (m :: * -> *) a b.
Functor m =>
a -> PrintCommands m b -> PrintCommands m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> PrintCommands m a -> PrintCommands m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> PrintCommands m a -> PrintCommands m b
fmap :: forall a b. (a -> b) -> PrintCommands m a -> PrintCommands m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> PrintCommands m b -> PrintCommands m a
<$ :: forall a b. a -> PrintCommands m b -> PrintCommands m a
Functor, Functor (PrintCommands m)
Functor (PrintCommands m) =>
(forall a. a -> PrintCommands m a)
-> (forall a b.
PrintCommands m (a -> b) -> PrintCommands m a -> PrintCommands m b)
-> (forall a b c.
(a -> b -> c)
-> PrintCommands m a -> PrintCommands m b -> PrintCommands m c)
-> (forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b)
-> (forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m a)
-> Applicative (PrintCommands m)
forall a. a -> PrintCommands m a
forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m a
forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
forall a b.
PrintCommands m (a -> b) -> PrintCommands m a -> PrintCommands m b
forall a b c.
(a -> b -> c)
-> PrintCommands m a -> PrintCommands m b -> PrintCommands m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (PrintCommands m)
forall (m :: * -> *) a. Applicative m => a -> PrintCommands m a
forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m a
forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m (a -> b) -> PrintCommands m a -> PrintCommands m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> PrintCommands m a -> PrintCommands m b -> PrintCommands m c
$cpure :: forall (m :: * -> *) a. Applicative m => a -> PrintCommands m a
pure :: forall a. a -> PrintCommands m a
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m (a -> b) -> PrintCommands m a -> PrintCommands m b
<*> :: forall a b.
PrintCommands m (a -> b) -> PrintCommands m a -> PrintCommands m b
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> PrintCommands m a -> PrintCommands m b -> PrintCommands m c
liftA2 :: forall a b c.
(a -> b -> c)
-> PrintCommands m a -> PrintCommands m b -> PrintCommands m c
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
*> :: forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m a
<* :: forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m a
Applicative, Applicative (PrintCommands m)
Applicative (PrintCommands m) =>
(forall a b.
PrintCommands m a -> (a -> PrintCommands m b) -> PrintCommands m b)
-> (forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b)
-> (forall a. a -> PrintCommands m a)
-> Monad (PrintCommands m)
forall a. a -> PrintCommands m a
forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
forall a b.
PrintCommands m a -> (a -> PrintCommands m b) -> PrintCommands m b
forall (m :: * -> *). Monad m => Applicative (PrintCommands m)
forall (m :: * -> *) a. Monad m => a -> PrintCommands m a
forall (m :: * -> *) a b.
Monad m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
forall (m :: * -> *) a b.
Monad m =>
PrintCommands m a -> (a -> PrintCommands m b) -> PrintCommands m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
PrintCommands m a -> (a -> PrintCommands m b) -> PrintCommands m b
>>= :: forall a b.
PrintCommands m a -> (a -> PrintCommands m b) -> PrintCommands m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
>> :: forall a b.
PrintCommands m a -> PrintCommands m b -> PrintCommands m b
$creturn :: forall (m :: * -> *) a. Monad m => a -> PrintCommands m a
return :: forall a. a -> PrintCommands m a
Monad, Monad (PrintCommands m)
Monad (PrintCommands m) =>
(forall a. IO a -> PrintCommands m a) -> MonadIO (PrintCommands m)
forall a. IO a -> PrintCommands m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (PrintCommands m)
forall (m :: * -> *) a. MonadIO m => IO a -> PrintCommands m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> PrintCommands m a
liftIO :: forall a. IO a -> PrintCommands m a
MonadIO)
instance MonadIO m => MonadCommand (PrintCommands m) where
executeCommand :: forall a. ToCommand a => a -> PrintCommands m ()
executeCommand = IO () -> PrintCommands m ()
forall a. IO a -> PrintCommands m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> PrintCommands m ())
-> (a -> IO ()) -> a -> PrintCommands m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO ()
forall a. ToCommand a => a -> IO ()
forall (m :: * -> *) a. (MonadCommand m, ToCommand a) => a -> m ()
executeCommand