Copyright | (c) 2018-2020 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Core of the mtl
implementation.
Synopsis
- newtype LoggerT msg m a = LoggerT {
- runLoggerT :: ReaderT (LogAction (LoggerT msg m) msg) m a
- type WithLog env msg m = (MonadReader env m, HasLog env msg m, HasCallStack)
- logMsg :: forall msg env m. WithLog env msg m => msg -> m ()
- logMsgs :: forall msg env f m. (Foldable f, WithLog env msg m) => f msg -> m ()
- withLog :: WithLog env msg m => (LogAction m msg -> LogAction m msg) -> m a -> m a
- liftLogAction :: (Monad m, MonadTrans t) => LogAction m msg -> LogAction (t m) msg
- usingLoggerT :: Monad m => LogAction m msg -> LoggerT msg m a -> m a
Documentation
newtype LoggerT msg m a Source #
newtype
wrapper ReaderT
that keeps LogAction
in its context.
LoggerT | |
|
Instances
MonadTrans (LoggerT msg) Source # | |
Defined in Colog.Monad | |
Monad m => Monad (LoggerT msg m) Source # | |
Functor m => Functor (LoggerT msg m) Source # | |
Applicative m => Applicative (LoggerT msg m) Source # | |
Defined in Colog.Monad pure :: a -> LoggerT msg m a # (<*>) :: LoggerT msg m (a -> b) -> LoggerT msg m a -> LoggerT msg m b # liftA2 :: (a -> b -> c) -> LoggerT msg m a -> LoggerT msg m b -> LoggerT msg m c # (*>) :: LoggerT msg m a -> LoggerT msg m b -> LoggerT msg m b # (<*) :: LoggerT msg m a -> LoggerT msg m b -> LoggerT msg m a # | |
MonadIO m => MonadIO (LoggerT msg m) Source # | |
Defined in Colog.Monad | |
Monad m => MonadReader (LogAction (LoggerT msg m) msg) (LoggerT msg m) Source # | |
type WithLog env msg m = (MonadReader env m, HasLog env msg m, HasCallStack) Source #
Type alias for constraint for:
- Monad
m
have access to environmentenv
. - Environment
env
containsLogAction
that can log messages of typemsg
. - Function call stack.
If you use this constraint, function call stack will be propagated and you will have access to code lines that log messages.
logMsgs :: forall msg env f m. (Foldable f, WithLog env msg m) => f msg -> m () Source #
Logs multiple messages.
liftLogAction :: (Monad m, MonadTrans t) => LogAction m msg -> LogAction (t m) msg Source #
Lifts LogAction
by allowing to log in a transformed monad.
usingLoggerT :: Monad m => LogAction m msg -> LoggerT msg m a -> m a Source #
Runner for LoggerT
monad. Let's consider one simple example of monadic
action you have:
app ::WithLog
envString
m => m () app = dologMsg
"Starting application..."withLog
(cmap
("app:" ++)) $ dologMsg
"Application started."logMsg
"Application finished."
You can use the following way of running such example:
usingLoggerT
(LogAction
putStrLn
) app
And you will see this output:
Starting application... app:Application started. app:Application finished.