| Copyright | (C) Dimitri Sabadie |
|---|---|
| License | BSD3 |
| Maintainer | dimitri.sabadie@gmail.com |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Monad.Journal.Class
Contents
Description
MonadWriter on steroids.
MonadJournal is a more controlable version of MonadWriter because it
enables you to access the Monoid being computed up. You can then access
logs inside the computation itself, whereas you cannot with
MonadWriter – unless you use specific functions like listen, but that
still stacks Monoid in the monad.
Typically, you can use MonadJournal when you come across the logging
problem and you need logs as long as you proceed.
- class (Monoid w, Monad m) => MonadJournal w m | m -> w where
- sink :: (MonadJournal w m, MonadIO m) => (w -> IO ()) -> m ()
- absorb :: MonadJournal w m => (a, w) -> m a
MonadJournal
class (Monoid w, Monad m) => MonadJournal w m | m -> w where Source
This typeclass provides the ability to accumulate Monoid in a monad
via the journal function; to get them via the history function and
finally, to purge them all with the clear function.
In most cases, you won’t need history neither clear. There’s a
cool function that combines both and enables you to deal with the
Monoid: sink.
Methods
Log something.
Extract the logs history.
Clear the logs history.
Instances
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (MaybeT m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (ListT m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (IdentityT m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (EitherT e m) | |
| (Monad m, Monoid w, Monoid q, MonadJournal w m) => MonadJournal w (WriterT q m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (StateT s m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (ReaderT r m) | |
| (Monoid w, Monad m) => MonadJournal w (JournalT w m) | |
| (Monad m, Monoid w, MonadJournal w m) => MonadJournal w (RWST r w s m) |
sink :: (MonadJournal w m, MonadIO m) => (w -> IO ()) -> m () Source
Sink all logs history through MonadIO then clean it.
absorb :: MonadJournal w m => (a, w) -> m a Source
Absorb a logs history and pass around the value.