monad-journal 0.4.0.2 → 0.5
raw patch · 6 files changed
+78/−37 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.Trans.Journal: data JournalT w m a
Files
- CHANGELOG.md +9/−3
- Control/Monad/Journal.hs +11/−10
- Control/Monad/Journal/Class.hs +27/−11
- Control/Monad/Trans/Journal.hs +17/−12
- README.md +12/−0
- monad-journal.cabal +2/−1
CHANGELOG.md view
@@ -1,14 +1,20 @@ # CHANGELOG +### 0.5++- license is now BSD3!;+- enhanced the documentation in all modules;+- added README.md.+ ### 0.4.0.2 - added the changelog in the package description (.cabal). ### 0.4.0.1 -- added the *source-repository head* field in the .cabal file ;-- added the *bug-reports* field in the .cabal file ;-- change *author* and *maintainer* format+- added the *source-repository head* field in the .cabal file;+- added the *bug-reports* field in the .cabal file;+- change *author* and *maintainer* format. ### 0.4
Control/Monad/Journal.hs view
@@ -1,13 +1,14 @@-{- |-Module : Control.Monad.Journal-Copyright : (c) Dimitri Sabadie-License : GPL-3--Maintainer : dimitri.sabadie@gmail.com-Stability : stable-Portability : portable---}+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) Dimitri Sabadie+-- License : BSD3+-- +-- Maintainer : dimitri.sabadie@gmail.com+-- Stability : stable+-- Portability : portable+--+-- This module re-exports anything about the 'MonadJournal' *typeclass*.+----------------------------------------------------------------------------- module Control.Monad.Journal ( module Control.Monad.Journal.Class
Control/Monad/Journal/Class.hs view
@@ -1,16 +1,25 @@ {-# LANGUAGE FunctionalDependencies, UndecidableInstances #-} -{- |-Module : Control.Monad.Journal.Class-Description : Journal monad typeclass-Copyright : (c) Dimitri Sabadie-License : GPL-3--Maintainer : dimitri.sabadie@gmail.com-Stability : stable-Portability : portable---}+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) Dimitri Sabadie+-- License : BSD3+-- +-- Maintainer : dimitri.sabadie@gmail.com+-- Stability : stable+-- Portability : portable+--+-- '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.+----------------------------------------------------------------------------- module Control.Monad.Journal.Class ( -- * MonadJournal@@ -31,6 +40,13 @@ import Control.Monad.Trans.Writer ( WriterT ) import Data.Monoid ( Monoid, mappend, mempty ) +-- |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'. class (Monoid w, Monad m) => MonadJournal w m | m -> w where -- |Log something. journal :: w -> m ()
Control/Monad/Trans/Journal.hs view
@@ -1,17 +1,21 @@ {-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, UndecidableInstances #-} {-# OPTIONS_HADDOCK prune #-} -{- |-Module : Control.Monad.Trans.Journal-Description : Journal monad transformer-Copyright : (c) Dimitri Sabadie-License : GPL-3--Maintainer : dimitri.sabadie@gmail.com-Stability : stable-Portability : portable---}+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) Dimitri Sabadie+-- License : BSD3+-- +-- Maintainer : dimitri.sabadie@gmail.com+-- Stability : stable+-- Portability : portable+--+-- Monad transformer version of 'MonadJournal'. 'JournalT' provides+-- journaling over a monad.+--+-- This modules defines a few useful instances. Check the list below for+-- further information.+----------------------------------------------------------------------------- module Control.Monad.Trans.Journal ( -- * JournalT monad transformer@@ -19,6 +23,7 @@ , runJournalT , evalJournalT , execJournalT+ -- * Re-exported , module Control.Monad.Journal.Class ) where @@ -39,7 +44,7 @@ import Data.Monoid ( Monoid(..) ) import qualified Control.Monad.State.Class as MS ( MonadState(..) ) -+-- |Transformer version of 'MonadJournal'. newtype JournalT w m a = JournalT (StateT w m a) deriving ( Applicative , Alternative
+ README.md view
@@ -0,0 +1,12 @@+# monad-journal++## Pure logger typeclass and monad transformer++### What is `monad-journal`?++`monad-journal` is a simple but powerful answer to the logging problem. A lot+of people think that “logging” is `IO`-related, while it’s not. Everyone must+know [MonadWriter](http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-Writer-Class.html#t:MonadWriter)+, which is perfect to log things in pure computations. The issue is that you+can’t access those “things” inside the computation itself. `monad-journal`+exposes a cool typeclass called `MonadJournal` that enables you to do so.
monad-journal.cabal view
@@ -1,6 +1,6 @@ name: monad-journal license: PublicDomain-version: 0.4.0.2+version: 0.5 synopsis: Pure logger typeclass and monad transformer description: This package provides a typeclass for logging in pure code, or more generally, in any kind of@@ -18,6 +18,7 @@ cabal-version: >= 1.10 extra-source-files: CHANGELOG.md+ , README.md source-repository head type: git