<p dir="ltr">In every case I can think of where an instance turned out to be a problem, that was because there were multiple law-abiding options and the designers chose the wrong one. Examples that at least some people disagree with:</p>
<p dir="ltr">instance Monoid a => Monoid (Maybe a)<br>
-- McBride has argued for mappend = (<|>) here instead.<br>
instance Monoid b => Monoid (a -> b)</p>
<p dir="ltr">-- McBride again, IIRC, dislikes this, weakly preferring<br>
-- instance a ~ b => Monoid (a -> b)</p>
<p dir="ltr">instance (Eq k,  Hashable k) => Monoid (HashMap k v)<br>
-- Almost everyone wants<br>
-- instance (Semigroup v, Hashable k) => Monoid (HashMap k v)</p>
<p dir="ltr">A Num instance for functions is a bad idea because it leads to terrible error messages, but I would argue that's a poor example. The (->) constructor has a sufficiently special, and sufficiently silent, role in the language that it requires a *uniquely* high level of care. When that care is taken (as with the Monad ((->) a) instance), things generally work out just fine.</p>
<div class="gmail_quote">On Jan 18, 2016 4:21 PM, "Tikhon Jelvis" <<a href="mailto:tikhon@jelv.is">tikhon@jelv.is</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>> I don't know why "I wouldn't use it" should extend to "it shouldn't exist".<br><br>I'm in favor of these instances, if only for the sake of consistency. However, I don't agree with this reasoning. Typeclass instances in Haskell are an inherently global construct: once an instance is defined, you can't do anything about it. You can't replace it or redefine it or even not import it. At the same time, it affects type inference and type error messages even if you're *not* using it.<br><br></div>As a slightly more extreme example, there's a reason we don't have a Num instance for functions or Applicatives by default: while perfectly well-formed and even useful, having these instances would lead to worse error messages or even code typechecking when it shouldn't with weird results—even if you never rely on them yourself.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 18, 2016 at 12:59 PM, Eric Seidel <span dir="ltr"><<a href="mailto:eric@seidel.io" target="_blank">eric@seidel.io</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Mon, Jan 18, 2016, at 12:44, Christopher Allen wrote:<br>
> I've addressed this here:<br>
><br>
> <a href="http://bitemyapp.com/posts/2015-10-19-either-is-not-arbitrary.html" rel="noreferrer" target="_blank">http://bitemyapp.com/posts/2015-10-19-either-is-not-arbitrary.html</a><br>
><br>
> The thousand-papercuts opposition to typeclass instances on the premise<br>
> that a Functor for (a, b, c) maps over the final type not making sense is a<br>
> rejection of how higher kinded types and typeclasses work together. This<br>
> is natural and predictable if one bothers to explain it.<br>
<br>
</span>The behavior is indeed predictable, but I think Henning is arguing (and<br>
I would agree) that it is *undesirable*.<br>
<br>
That being said, I think the ship has sailed on the "should tuples be a<br>
Functor/etc" discussion. The current proposal is aimed at making the set<br>
of available instances more consistent across tuples, which I'd argue is<br>
a good thing regardless of one's position on the specific class.<br>
<div><div>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div>