Safe Haskell | Safe-Inferred |
---|
A monad like WriterT, but intended for logging.
WriterT is not actually all that good for logging because its (>>=) is not tail recursive.
TODO there's now a CPS version on hackage: writer-cps-mtl It might be more efficient.
Synopsis
- data LoggerT w m a
- type Logger w a = LoggerT w Identity a
- run :: Monad m => LoggerT w m a -> m (a, [w])
- runId :: Logger w a -> (a, [w])
- exec :: Monad m => LoggerT w m a -> m [w]
- class Monad m => MonadLogger w m | m -> w where
- logs :: MonadLogger w m => [w] -> m ()
- mapLogs :: (w -> w) -> Logger w a -> Logger w a
Documentation
This uses a plain list for now. DList is not actually very efficient for appends because appending nil doesn't strictly eliminate the nil.
Instances
Monad m => MonadLogger w (LoggerT w m) Source # | |
MonadError e m => MonadError e (LoggerT w m) Source # | |
Defined in Util.Logger throwError :: e -> LoggerT w m a # catchError :: LoggerT w m a -> (e -> LoggerT w m a) -> LoggerT w m a # | |
MonadReader r m => MonadReader r (LoggerT w m) Source # | |
MonadState s m => MonadState s (LoggerT w m) Source # | I think I can't automatically derive this because LoggerT itself is a StateT. |
MonadTrans (LoggerT w) Source # | |
Defined in Util.Logger | |
MonadIO m => MonadIO (LoggerT w m) Source # | |
Defined in Util.Logger | |
Monad m => Applicative (LoggerT w m) Source # | |
Defined in Util.Logger | |
Functor m => Functor (LoggerT w m) Source # | |
Monad m => Monad (LoggerT w m) Source # | |
class Monad m => MonadLogger w m | m -> w where Source #
Instances
(Monoid w, MonadLogger log m) => MonadLogger log (WriterT w m) Source # | |
Monad m => MonadLogger w (LoggerT w m) Source # | |
(Error e, MonadLogger w m) => MonadLogger w (Error.ErrorT e m) Source # | |
Defined in Util.Logger log :: w -> Error.ErrorT e m () Source # peek :: Error.ErrorT e m [w] Source # | |
MonadLogger w m => MonadLogger w (Except.ExceptT e m) Source # | |
Defined in Util.Logger log :: w -> Except.ExceptT e m () Source # peek :: Except.ExceptT e m [w] Source # | |
MonadLogger w m => MonadLogger w (Reader.ReaderT r m) Source # | |
Defined in Util.Logger log :: w -> Reader.ReaderT r m () Source # peek :: Reader.ReaderT r m [w] Source # | |
MonadLogger w m => MonadLogger w (Lazy.StateT s m) Source # | |
Defined in Util.Logger log :: w -> Lazy.StateT s m () Source # peek :: Lazy.StateT s m [w] Source # | |
MonadLogger w m => MonadLogger w (Strict.StateT s m) Source # | |
Defined in Util.Logger log :: w -> Strict.StateT s m () Source # peek :: Strict.StateT s m [w] Source # |
logs :: MonadLogger w m => [w] -> m () Source #