Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Util.Logger

Description

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

Documentation

data LoggerT w m a Source #

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

Instances details
Monad m => MonadLogger w (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> LoggerT w m () Source #

peek :: LoggerT w m [w] Source #

MonadError e m => MonadError e (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

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 # 
Instance details

Defined in Util.Logger

Methods

ask :: LoggerT w m r #

local :: (r -> r) -> LoggerT w m a -> LoggerT w m a #

reader :: (r -> a) -> LoggerT w m a #

MonadState s m => MonadState s (LoggerT w m) Source #

I think I can't automatically derive this because LoggerT itself is a StateT.

Instance details

Defined in Util.Logger

Methods

get :: LoggerT w m s #

put :: s -> LoggerT w m () #

state :: (s -> (a, s)) -> LoggerT w m a #

MonadTrans (LoggerT w) Source # 
Instance details

Defined in Util.Logger

Methods

lift :: Monad m => m a -> LoggerT w m a #

MonadIO m => MonadIO (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

liftIO :: IO a -> LoggerT w m a #

Monad m => Applicative (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

pure :: a -> LoggerT w m a #

(<*>) :: LoggerT w m (a -> b) -> LoggerT w m a -> LoggerT w m b #

liftA2 :: (a -> b -> c) -> LoggerT w m a -> LoggerT w m b -> LoggerT w m c #

(*>) :: LoggerT w m a -> LoggerT w m b -> LoggerT w m b #

(<*) :: LoggerT w m a -> LoggerT w m b -> LoggerT w m a #

Functor m => Functor (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

fmap :: (a -> b) -> LoggerT w m a -> LoggerT w m b #

(<$) :: a -> LoggerT w m b -> LoggerT w m a #

Monad m => Monad (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

(>>=) :: LoggerT w m a -> (a -> LoggerT w m b) -> LoggerT w m b #

(>>) :: LoggerT w m a -> LoggerT w m b -> LoggerT w m b #

return :: a -> LoggerT w m a #

type Logger w a = LoggerT w Identity a Source #

run :: Monad m => LoggerT w m a -> m (a, [w]) Source #

runId :: Logger w a -> (a, [w]) Source #

exec :: Monad m => LoggerT w m a -> m [w] Source #

class Monad m => MonadLogger w m | m -> w where Source #

Methods

log :: w -> m () Source #

peek :: m [w] Source #

Instances

Instances details
(Monoid w, MonadLogger log m) => MonadLogger log (WriterT w m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: log -> WriterT w m () Source #

peek :: WriterT w m [log] Source #

Monad m => MonadLogger w (LoggerT w m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> LoggerT w m () Source #

peek :: LoggerT w m [w] Source #

(Error e, MonadLogger w m) => MonadLogger w (Error.ErrorT e m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> Error.ErrorT e m () Source #

peek :: Error.ErrorT e m [w] Source #

MonadLogger w m => MonadLogger w (Except.ExceptT e m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> Except.ExceptT e m () Source #

peek :: Except.ExceptT e m [w] Source #

MonadLogger w m => MonadLogger w (Reader.ReaderT r m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> Reader.ReaderT r m () Source #

peek :: Reader.ReaderT r m [w] Source #

MonadLogger w m => MonadLogger w (Lazy.StateT s m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> Lazy.StateT s m () Source #

peek :: Lazy.StateT s m [w] Source #

MonadLogger w m => MonadLogger w (Strict.StateT s m) Source # 
Instance details

Defined in Util.Logger

Methods

log :: w -> Strict.StateT s m () Source #

peek :: Strict.StateT s m [w] Source #

logs :: MonadLogger w m => [w] -> m () Source #

mapLogs :: (w -> w) -> Logger w a -> Logger w a Source #