Is there any way of detecting redundant constraints in Haskell?
For example:
class (A a, B a) => C1 a -- C1 ~ A AND B
instance (A a, B a) => C1 a
class (A a, B a, C a) => C2 a
instance (A a, B a, C a) => C2 a
f :: (C1 a, C2 a) => a
f = ...
Here, C2 implies C1, and use of C1 in the signature of f is redundant, i.e. tautological.
In a real-world metaprogramming situation, This would be waaaay more complex, and would significantly help de-clutter signature heads, as well as help me understand and keep track of what is going on.
Is this logically possible, given GHC's formalism?
Is the infrastructure available within GHC?