I realise that the answer may be that there are multiple valid such instances (as is the case for e.g. integers; sum, product, ...). Perhaps someone has a more satisfying answer than this?
As Joachim Breitner excellently explains in this answer How do you implement monoid interface for this tree in haskell? any applicative has a monoid instance:
mempty :: Applicative f => Monoid a => f a
mempty = pure mempty
mappend :: Applicative f => Monoid a => f a -> f a -> f a
mappend f g = mappend <$> f <*> g
So I was wondering why Data.Tree.Tree
from containers
does not have such an instance? Same argument could be used for any other monad without an accompanying monoid instance. It only seems natural to me that they should have such instances. Maybe this is not the case. I hope someone can enlighten me.
I suppose another reason could be that the instance I propose for trees is not "useful". This is as unsatisfying as the multiple valid instances argument in my opinion.