{-# LANGUAGE UndecidableInstances #-}
module Control.Carrier.Logging.Silent (SilentLoggingC (..)) where
import Control.Algebra (Algebra (alg), (:+:) (L, R))
import Control.Effect.Logging (Logging (LoggerLog))
import Control.Monad.Identity (IdentityT (IdentityT))
import UnliftIO (MonadIO, MonadUnliftIO)
newtype SilentLoggingC m a = MkSilentLoggingC {forall {k} (m :: k -> *) (a :: k). SilentLoggingC m a -> m a
runSilentLogging :: m a}
deriving
((forall a b. (a -> b) -> SilentLoggingC m a -> SilentLoggingC m b)
-> (forall a b. a -> SilentLoggingC m b -> SilentLoggingC m a)
-> Functor (SilentLoggingC m)
forall a b. a -> SilentLoggingC m b -> SilentLoggingC m a
forall a b. (a -> b) -> SilentLoggingC m a -> SilentLoggingC m b
forall (m :: * -> *) a b.
Functor m =>
a -> SilentLoggingC m b -> SilentLoggingC m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> SilentLoggingC m a -> SilentLoggingC 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) -> SilentLoggingC m a -> SilentLoggingC m b
fmap :: forall a b. (a -> b) -> SilentLoggingC m a -> SilentLoggingC m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> SilentLoggingC m b -> SilentLoggingC m a
<$ :: forall a b. a -> SilentLoggingC m b -> SilentLoggingC m a
Functor, Functor (SilentLoggingC m)
Functor (SilentLoggingC m)
-> (forall a. a -> SilentLoggingC m a)
-> (forall a b.
SilentLoggingC m (a -> b)
-> SilentLoggingC m a -> SilentLoggingC m b)
-> (forall a b c.
(a -> b -> c)
-> SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m c)
-> (forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b)
-> (forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m a)
-> Applicative (SilentLoggingC m)
forall a. a -> SilentLoggingC m a
forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m a
forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
forall a b.
SilentLoggingC m (a -> b)
-> SilentLoggingC m a -> SilentLoggingC m b
forall a b c.
(a -> b -> c)
-> SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC 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 (SilentLoggingC m)
forall (m :: * -> *) a. Applicative m => a -> SilentLoggingC m a
forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m a
forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m (a -> b)
-> SilentLoggingC m a -> SilentLoggingC m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m c
$cpure :: forall (m :: * -> *) a. Applicative m => a -> SilentLoggingC m a
pure :: forall a. a -> SilentLoggingC m a
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m (a -> b)
-> SilentLoggingC m a -> SilentLoggingC m b
<*> :: forall a b.
SilentLoggingC m (a -> b)
-> SilentLoggingC m a -> SilentLoggingC m b
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m c
liftA2 :: forall a b c.
(a -> b -> c)
-> SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m c
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
*> :: forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m a
<* :: forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m a
Applicative, Applicative (SilentLoggingC m)
Applicative (SilentLoggingC m)
-> (forall a b.
SilentLoggingC m a
-> (a -> SilentLoggingC m b) -> SilentLoggingC m b)
-> (forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b)
-> (forall a. a -> SilentLoggingC m a)
-> Monad (SilentLoggingC m)
forall a. a -> SilentLoggingC m a
forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
forall a b.
SilentLoggingC m a
-> (a -> SilentLoggingC m b) -> SilentLoggingC m b
forall {m :: * -> *}. Monad m => Applicative (SilentLoggingC m)
forall (m :: * -> *) a. Monad m => a -> SilentLoggingC m a
forall (m :: * -> *) a b.
Monad m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
forall (m :: * -> *) a b.
Monad m =>
SilentLoggingC m a
-> (a -> SilentLoggingC m b) -> SilentLoggingC 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 =>
SilentLoggingC m a
-> (a -> SilentLoggingC m b) -> SilentLoggingC m b
>>= :: forall a b.
SilentLoggingC m a
-> (a -> SilentLoggingC m b) -> SilentLoggingC m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
>> :: forall a b.
SilentLoggingC m a -> SilentLoggingC m b -> SilentLoggingC m b
$creturn :: forall (m :: * -> *) a. Monad m => a -> SilentLoggingC m a
return :: forall a. a -> SilentLoggingC m a
Monad, Monad (SilentLoggingC m)
Monad (SilentLoggingC m)
-> (forall a. IO a -> SilentLoggingC m a)
-> MonadIO (SilentLoggingC m)
forall a. IO a -> SilentLoggingC m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall {m :: * -> *}. MonadIO m => Monad (SilentLoggingC m)
forall (m :: * -> *) a. MonadIO m => IO a -> SilentLoggingC m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> SilentLoggingC m a
liftIO :: forall a. IO a -> SilentLoggingC m a
MonadIO, Monad (SilentLoggingC m)
Monad (SilentLoggingC m)
-> (forall a. String -> SilentLoggingC m a)
-> MonadFail (SilentLoggingC m)
forall a. String -> SilentLoggingC m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall {m :: * -> *}. MonadFail m => Monad (SilentLoggingC m)
forall (m :: * -> *) a. MonadFail m => String -> SilentLoggingC m a
$cfail :: forall (m :: * -> *) a. MonadFail m => String -> SilentLoggingC m a
fail :: forall a. String -> SilentLoggingC m a
MonadFail, MonadIO (SilentLoggingC m)
MonadIO (SilentLoggingC m)
-> (forall b.
((forall a. SilentLoggingC m a -> IO a) -> IO b)
-> SilentLoggingC m b)
-> MonadUnliftIO (SilentLoggingC m)
forall b.
((forall a. SilentLoggingC m a -> IO a) -> IO b)
-> SilentLoggingC m b
forall (m :: * -> *).
MonadIO m
-> (forall b. ((forall a. m a -> IO a) -> IO b) -> m b)
-> MonadUnliftIO m
forall {m :: * -> *}. MonadUnliftIO m => MonadIO (SilentLoggingC m)
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. SilentLoggingC m a -> IO a) -> IO b)
-> SilentLoggingC m b
$cwithRunInIO :: forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. SilentLoggingC m a -> IO a) -> IO b)
-> SilentLoggingC m b
withRunInIO :: forall b.
((forall a. SilentLoggingC m a -> IO a) -> IO b)
-> SilentLoggingC m b
MonadUnliftIO)
via IdentityT m
instance Algebra sig m => Algebra (Logging :+: sig) (SilentLoggingC m) where
alg :: forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n (SilentLoggingC m)
-> (:+:) Logging sig n a -> ctx () -> SilentLoggingC m (ctx a)
alg Handler ctx n (SilentLoggingC m)
hdl (:+:) Logging sig n a
sig ctx ()
ctx = case (:+:) Logging sig n a
sig of
L (LoggerLog LogMsg
_msg) -> m (ctx a) -> SilentLoggingC m (ctx a)
forall {k} (m :: k -> *) (a :: k). m a -> SilentLoggingC m a
MkSilentLoggingC (ctx a
ctx ()
ctx ctx a -> m () -> m (ctx a)
forall a b. a -> m b -> m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ () -> m ()
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
R sig n a
other -> m (ctx a) -> SilentLoggingC m (ctx a)
forall {k} (m :: k -> *) (a :: k). m a -> SilentLoggingC m a
MkSilentLoggingC do
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg (SilentLoggingC m (ctx x) -> m (ctx x)
forall {k} (m :: k -> *) (a :: k). SilentLoggingC m a -> m a
runSilentLogging (SilentLoggingC m (ctx x) -> m (ctx x))
-> (ctx (n x) -> SilentLoggingC m (ctx x))
-> ctx (n x)
-> m (ctx x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ctx (n x) -> SilentLoggingC m (ctx x)
Handler ctx n (SilentLoggingC m)
hdl) sig n a
other ctx ()
ctx