monad-journal-0.7.2: Pure logger typeclass and monad transformer

Copyright(C) Dimitri Sabadie
LicenseBSD3
Maintainerdimitri.sabadie@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

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.

Synopsis

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

journal :: w -> m () Source

Log something.

history :: m w Source

Extract the logs history.

clear :: m () Source

Clear the logs history.

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.