Proposal: Add the orphan instance Monoid e => Monad ((, )e) to Data.Monoid
ekmett at gmail.com
Sat Nov 12 21:29:47 CET 2011
I propose adding an (orphan) instance of Monad for ((,) e) to Data.Monoid.
Discussion deadline: 2 weeks from now (November 26)
== Current State ==
== The Issues ==
Control.Applicative already exports a compatible instance for Applicative
for ((,) e), but there isn't a canonical place to get the compatible Monad.
== Proposed enhancement ==
Add the following orphan instance to Data.Monoid.
instance Monoid e => Monad ((,) e) where return a = (a, mempty)
(w,a) >>= k = (mappend w w', b)
where (w',b) = k a
Monoid isn't exported from the Prelude, so there is currently no place
for this instance to live currently that doesn't render it an orphan.
== Alternative ==
We could place this instance in Control.Monad.Instances which is where
we've placed similar instances in the past.
However, this would increase the likelihood of failure to properly import
the instance for users, who would have to know to import both Data.Monoid
and Control.Monad.Instances, rather than just Data.Monoid.
Moreover in a separate active proposal I've just proposed moving all the
Control.Monad.Instances instances out, so in the event that that proposal
is adopted this would be unsatisfyingly the only instance there.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries