Proposal: Add the orphan instance Monoid e => Monad ((, )e) to Data.Monoid
Edward Kmett
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 ==
No instance
== 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
Why?
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.
-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20111112/d4ba612e/attachment.htm>
More information about the Libraries
mailing list