Lets say I've got the following data type:
data D c a b = D (c a b) (c b a)
And I define a function to manipulate it:
apply :: (c a b -> c a2 b2) -> (c b a -> c b2 a2) -> D c a b -> D c a2 b2
apply f1 f2 (D x y) = D (f1 x) (f2 y)
This is all fine. But I want a shorter function if (f1 = f2). So I write:
applyBoth f = apply f f
I originally thought that if "apply f f" is valid, then logically "applyBoth f" should also be valid. But it seems that type inference results in applyBoth only working for functions "c a a -> c a2 a2".
Is there a way to type "applyBoth" so it works for all functions that would work simply by repeating them twice in "apply"?