[Haskell-cafe] Applicative Monoid instance

Will Yager will.yager at gmail.com
Mon Sep 5 19:28:21 UTC 2016


Probably something to do with not making overlapping instances. Not sure. 

Easiest/best approach is probably to make a newtype wrapper around IO or IO (). Then you can define the monoid instance you want. 

Will

> On Sep 5, 2016, at 13:54, Brian Hurt <bhurt at spnz.org> wrote:
> 
> 
> This may be a stupid question, but I'm wondering why the following instance isn't in prelude:
> 
> instance (Applicative m, Monoid a) => Monoid (m a) where
>     mempty = pure mempty
>     mappend a b = mappend <$> a <*> b
> 
> ?
> 
> I ask, because being able to use a WriterT (IO ()) STM a to debug complex STM expressions would be really nice.  But it depends upon IO () being a monoid.
> 
> Brian
> 
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the Haskell-Cafe mailing list