Skip to content

More general Eq+Ord+Read+Show instances for Data.Functor.Product

Motivation

Data.Functor.Product currently has instances for Eq, Ord, Read, and Show which are based on Eq1, Ord1, Read1, and Show1, which implicitly assume that:

  • The a type variable in Product f g a has a representational role
  • The f and g type variables have kind Type -> Type

These assumptions are not always correct, for example:

  • There's no reason that Eq (Product (Const Int) (Const Bool) a) should require Eq a, but it does
  • PolyKinds instances of Product can't currently have Eq instances because Eq1 can't be provided for f because it has the wrong kind

When needing these instances, the problem currently cannot be worked around using orphan instances, as those overlap the original instances.

Proposal

Replace the current limited Eq, Ord, Read, and Show instances of Product with more general instances.

This is a matter of simply removing the current instances and adding , Eq, Ord, Read, Show to Product's deriving clause.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information