Monoid instances for mtl
Henning Thielemann
lemming at henning-thielemann.de
Tue Jul 7 05:49:11 EDT 2009
On Mon, 6 Jul 2009, Stefan Holdermans wrote:
> Hi all,
>
> On a number of occasions I found myself declaring simple instances like
>
> instance Monoid a => Monoid (State s a) where
> mzero = return mzero
> mappend = liftM2 mappend
>
> that make my life considerably easier. Would it be a good idea to add such
> instances to the Monad Transformer Library?
... and to 'transformers'. However, in 'transformers' we had to define it
for StateT, since (State s) is a synonym for (StateT s Identity). But I
think this is a good idea anyway.
I also need this instance occasionally and had written a custom data type
for this purpose:
http://hackage.haskell.org/packages/archive/monoid-transformer/0.0.1/doc/html/Data-Monoid-State.html
Since it does only need Applicative functionality it can be defined for
all other types in MTL.
More information about the Libraries
mailing list