<p dir="ltr">I love the idea of adding support for such a warning, but I think core2core is likely too late to do the job properly. The instance resolution information is (currently, at least) thrown out altogether once the type checker finishes its job. And even the slightest bit of inlining of external modules could give false positives. I would think the easiest way would be to add a "suppressed instance" structure to the type checker. It would basically be a stripped-down analogue of the big instance database the type checker uses for instance resolution. When resolving an instance, the type checker would first check the suppressed instance set for it; if it found it there, it would fail or warn as appropriate. So I could write something like</p>
<p dir="ltr">{-# SuppressInstance Functor ((,) a) #-}</p>
<p dir="ltr">But I could also write something more subtle like</p>
<p dir="ltr">{-# WarnInstance Semigroup v => Monoid (HashMap k v) #-}</p>
<p dir="ltr">which would only warn me if I use the Monoid instance for a HashMap whose values form a semigroup.</p>
<div class="gmail_quote">On Jan 18, 2016 4:31 PM, "Eric Seidel" <<a href="mailto:eric@seidel.io">eric@seidel.io</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jan 18, 2016, at 13:22, Henning Thielemann wrote:<br>
><br>
> On Mon, 18 Jan 2016, John Wiegley wrote:<br>
><br>
> >>>>>> Henning Thielemann <<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>> writes:<br>
> ><br>
> >> I would never use such an instance. Can I be warned if I accidentally use it<br>
> >> anyway?<br>
> ><br>
> > I don't know why "I wouldn't use it" should extend to "it shouldn't exist".<br>
><br>
> Because I cannot turn it off and I cannot get warning. It is inserted by<br>
> GHC whenever it matches, even if I made a mistake when programming.<br>
<br>
There may be an easier way, but one could write a Core-to-Core plugin<br>
that kills the build if it sees an expression like `fmap @(,)`.<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>
</blockquote></div>