Move Data.Functor.Contravariant into base
Andrew Martin
andrew.thaddeus at gmail.com
Thu Dec 15 01:25:06 UTC 2016
The deriving problem is annoying indeed. I stumbled across that github
issue shortly after proposing this change. The only sensible thing I can
think of for a DeriveContravariant would be to only allow it if a data
type were only parameterized by things that were not higher-kinded. I'm
guessing that this is what you are describing when you say:
The other DeriveFoo definitions all do reasonable things. This can't do
a reasonable thing in any non-trivial situation.
Although I think that those "trivial situations" are common enough that
a necessarily imperfect DeriveContravariant could still be useful.
Regardless, it's the move into base that I care more about, so I'm glad
to hear that you find that agreeable.
-Andrew Martin
On Tue, Dec 13, 2016 at 01:35:57PM -0500, Edward Kmett wrote:
> I have no particular issue with moving Contravariant into base.
>
> That said, DeriveContravariant doesn't work out as well as you'd think. See
> the discussion in here: https://github.com/ekmett/contravariant/issues/17
> (There were other, longer discussions elsewhere that were er.. more of a
> discussion, but they were mostly on places like #haskell-lens which aren't
> logged and I can't find them at the moment.)
>
> With covariance you can just ignore that contravariant cases exist and get
> reasonable deriving.
>
> With contravariance composition of contravariant functors is covariant. You
> have the f (g a) problem. Which of the two is contravariant? This doesn't
> arise solely from type arguments. When faced with a concrete data type, you
> can't just look for a Contravariant or Functor instance for it, because
> both might be available (think Proxy). So the whole extension becomes a
> bug-addled mess.
>
> e.g. There are two sensible Contravariant instances for Compose, but
> neither one is canonical.
>
> The other DeriveFoo definitions all do reasonable things. This can't do a
> reasonable thing in any non-trivial situation.
>
> -Edward
>
> On Sun, Dec 11, 2016 at 11:14 AM, Andrew Martin <andrew.thaddeus at gmail.com>
> wrote:
>
> > The typeclass Contravariant (from the contravariant package) is both
> > useful and fundamental. I would like to see this moved into base.
> > One additional motivating factor is that it would become possible
> > for a DeriveContravariant extension to be written in a future GHC
> > release. I'd love to hear other people's thoughts, even if it's as
> > simple as a yea or nay. Thanks.
> >
> > -Andrew Martin
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> >
More information about the Libraries
mailing list