Thanks, Conor.  I like your reason of appealing to f structure over t structure in (f t).  And, yes I'd forgotten to mention that the monoid instance I suggested is exactly the one that holds for the representation (under the newtype).
<br><br>Deriving works just fine here:<br><br><span style="font-family: courier new,monospace;">&nbsp; &nbsp; deriving instance Monoid (Cont r a)</span><br><br>Cheers, - Conal<br><br><div><span class="gmail_quote">On 9/9/07, <b class="gmail_sendername">
Conor McBride</b> &lt;<a href="mailto:ctm@cs.nott.ac.uk">ctm@cs.nott.ac.uk</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Conal<br><br>Conal:<br> &gt; I&#39;d like to see the following addition to Control.Monad.Cont in mtl:<br> &gt;<br> &gt; instance Monoid r =&gt; Monoid (Cont r a) where<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; mempty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Cont mempty<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; m `mappend` m&#39; = Cont (runCont m `mappend` runCont m&#39;)
<br><br>Does newtype deriving work here?<br><br>Stefan:<br> &gt; (My 2 cents: Why not mempty = return mempty; mappend = liftM2<br>mappend ?<br> &gt; Instances are best if unambiguous.)<br><br>Conal:<br> &gt; I sure don&#39;t know how to resolve these situations of more than one
<br>credible<br> &gt; instance.&nbsp;&nbsp;I&#39;m seeing more &amp; more of them.<br><br>My usual rule of thumb is that inherent natural monoidal structure<br>should have<br>a higher priority than just applicative lifting of monoidal structure
<br>from the<br>value type. Here it&#39;s a bit harder to call because it&#39;s a choice of<br>two lifts,<br>but I&#39;d suggest that (Cont r) has natural monoidal structure if r is<br>a monoid,<br>and hence this should take precedence over the applicative lifting
<br>(which is<br>what liftM2 does, but with too restrictive a type).<br><br>I guess my fairly feeble reason for this rule of thumb is that it<br>fits with<br>what one would expect for []. It may also be to do with the way I
<br>read types:<br>when I see a type application (f t), I think of it as an f-like thing<br>with<br>t-like details, hence the natural properties of f are somehow the more<br>significant. Moreover, preferring the f-specific thing is no big deal
<br>if you<br>have a cheap and uniform way to get the other thing (eg, liftA2 or idiom<br>brackets). The f-specific thing usually requires special<br>consideration, hence<br>benefits most from overloading.<br><br>So I&#39;m with you on this one.
<br><br>All the best<br><br>Conor<br><br></blockquote></div><br>