Instancing tuples

71 Views Asked by At

I have a class, C, of * -> * types.

class C f where
  foo :: f a -> a -> a

I also have two types, A and B, which are instances of C

instance C A where
  foo a x = ...

instance C B where
  foo b x = ...

For various reasons, I also want the type D, defined as follows, to be an instance of C.

type D x = (A x, B x)

According to the answer to this question, type synonyms can't be partially applied, and to define the instance as I would like, I either need to define it in steps (preferable) or define D as a newtype (less preferable). It seems to me like there should be some way to accomplish the former, but I haven't been able to figure one out so far. Any help is appreciated.

0

There are 0 best solutions below