I also agree with Henning.<div><br></div><div>If anything, the 1st instance could be a ContT instance for Monoid.<br><div><br></div><div><div>instance (Monoid r, Monad m) => Monoid (ContT r m a) where</div><div> mempty = ContT $ const $ return mempty</div>
<div> m `mappend` n = ContT $ \ c -> liftM2 mappend (runContT m c) (runContT n c)</div></div><div><br></div><div>That way both behaviors are easily accessible. Is there any other sensible ContT instance for Monoid?</div>
<div><br clear="all"><div>-- Dan Burton</div>
<br><br><div class="gmail_quote">On Mon, Jun 24, 2013 at 11:23 AM, Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I agree with Henning.<div><br></div><div>I've historically used the moral equivalent of the second one far more than the first.<div><br></div><div>I have used both though. For instance, Numeric.Covector in the algebra package is a semantically restricted form of Cont that uses the equivalent of the first method.</div>
<div><br></div><div>The second form goes out of its way to preserve more of the existing semantics of the transformer stack and I'd dare say that if such an instance was added, it'd be closer to the expected behavior for more users.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>-Edward</div></font></span><div><div class="h5"><div><br><div class="gmail_quote">On Mon, Jun 24, 2013 at 1:53 PM, Henning Thielemann <span dir="ltr"><<a href="mailto:lemming@henning-thielemann.de" target="_blank">lemming@henning-thielemann.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>
On Mon, 24 Jun 2013, John Wiegley wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ross Paterson <<a href="mailto:R.Paterson@city.ac.uk" target="_blank">R.Paterson@city.ac.uk</a>> writes:<br>
</blockquote></blockquote></blockquote></blockquote></blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Alistair Lynn has proposed the following instance:<br>
<br>
instance (Monoid r, Monad m) => MonadPlus (ContT r m) where<br>
mzero = ContT $ const $ return mempty<br>
m `mplus` n = ContT $ \ c -> liftM2 mappend (runContT m c) (runContT n c)<br>
<br>
but this would also be possible:<br>
<br>
instance (MonadPlus m) => MonadPlus (ContT r m) where<br>
mzero = ContT $ const mzero<br>
m `mplus` n = ContT $ \ c -> runContT m c `mplus` runContT n c<br>
<br>
Is one of them better?<br>
</blockquote>
<br>
I would think that allowing ContT to transform any Monad over any Monoid has<br>
more utility than only transforming another MonadPlus. But I have no real<br>
world data to back this up, just a hunch.<br>
</blockquote>
<br></div>
I guess that if someone has a MonadPlus monad, then he wants to continue to use it when the monad stack grows by a ContT. This would give preference to the second instance.<div><div><br>
<br>
______________________________<u></u>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div></div>