Deriving Contravariant and Profunctor

Edward Kmett ekmett at
Fri Sep 11 17:52:35 UTC 2015

Actually it is trickier than you'd think.

With "Functor" you can pretend that contravariance doesn't exist.

With both profunctor and contravariant it is necessarily part of the puzzle.

data Compose f g a = Compose (f (g a))

* are both f and g contravariant leading to a functor?
* is f contravariant and g covariant leading to a contravariant functor?
* is f covariant and g contravariant leading to a contravariant functor?

data Wat p f a b = Wat (p (f a) b)

is p a Profunctor or a Bifunctor? is f Contravariant or a Functor?

We investigated adding TH code-generation for the contravariant package,
and ultimately rejected it on these grounds.


On Fri, Sep 11, 2015 at 12:49 PM, David Feuer <david.feuer at> wrote:

> Would it be possible to add mechanisms to derive Contravariant and
> Profunctor instances? As with Functor, each algebraic datatype can
> only have one sensible instance of each of these.
> David Feuer
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list