Profunctor but with three contravariant parameters

68 views Asked by At

I've got a type T with the following function defined on it:

tMap :: (a' -> a) -> (b' -> b) -> (c' -> c) -> (d -> d') -> T a b c d -> T a' b' c' d'
tMap = ...

Basically T is a profunctor but with three contravariant parameters instead of the usual one.

I thought what might be nice is if I could make my type just an ordinary profunctor. Which would save me having to write up special syntax for my type, and I could reuse any existing machinery in the profunctor library. So my first try was this:

data U abc d where
  U :: T a b c d -> U (a, b, c) d

instance Profunctor U where
  dimap f g (U x) = U (tMap ... x)

But this just doesn't work for a number of different reasons, one of which is that I can't see a way to exact a' -> a out of (a', b', c') -> (a, b, c), and also that you could pass Int -> (Int, Int, Int), and then you're stuck as there's no U Int blah constructor.

I suspect what I'm trying to do is impossible, but I thought I'd ask incase I was missing some transformation that reasonably makes my type a profunctor, aside from something like just ignoring the first two contravariant arguments by doing something like:

instance Profunctor (T a b) ...
0

There are 0 answers