Proposal: Add conspicuously missing Functor instances for tuples

David Feuer david.feuer at gmail.com
Mon Jan 18 23:19:05 UTC 2016


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

{-# SuppressInstance Functor ((,) a) #-}

But I could also write something more subtle like

{-# WarnInstance Semigroup v => Monoid (HashMap k v) #-}

which would only warn me if I use the Monoid instance for a HashMap whose
values form a semigroup.
On Jan 18, 2016 4:31 PM, "Eric Seidel" <eric at seidel.io> wrote:

> On Mon, Jan 18, 2016, at 13:22, Henning Thielemann wrote:
> >
> > On Mon, 18 Jan 2016, John Wiegley wrote:
> >
> > >>>>>> Henning Thielemann <lemming at henning-thielemann.de> writes:
> > >
> > >> I would never use such an instance. Can I be warned if I accidentally
> use it
> > >> anyway?
> > >
> > > I don't know why "I wouldn't use it" should extend to "it shouldn't
> exist".
> >
> > Because I cannot turn it off and I cannot get warning. It is inserted by
> > GHC whenever it matches, even if I made a mistake when programming.
>
> There may be an easier way, but one could write a Core-to-Core plugin
> that kills the build if it sees an expression like `fmap @(,)`.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160118/46763222/attachment.html>


More information about the Libraries mailing list