Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

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
MonadState s m => MonadState s (LoggerT w m) #

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 #

MonadReader r m => MonadReader r (LoggerT w m) # 
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 #

MonadError e m => MonadError e (LoggerT w m) # 
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 #

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

Defined in Util.Logger

Methods

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

peek :: LoggerT w m [w] Source #

MonadTrans (LoggerT w) # 
Instance details

Defined in Util.Logger

Methods

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

Monad m => Monad (LoggerT w m) # 
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 #

fail :: String -> LoggerT w m a #

Functor m => Functor (LoggerT w m) # 
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 => Applicative.Applicative (LoggerT w m) # 
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 #

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

Defined in Util.Logger

Methods

liftIO :: IO 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 #

Minimal complete definition

log, peek

Methods

log :: w -> m () Source #

peek :: m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: WriterT w m [log] Source #

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

Defined in Util.Logger

Methods

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

peek :: ExceptT e m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: ErrorT e m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: StateT s m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: StateT s m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: LoggerT w m [w] Source #

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

Defined in Util.Logger

Methods

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

peek :: ReaderT r m [w] Source #

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

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