Is there a a function that can take a given context/[Pred] and simplify it?
Some examples for what I mean by that:
- If the context contains
Eq [a]replace it withEq a(because it implies the more complicated constraint) - If the context contains
Eq Int, filter that out - Remove duplications
Use case: I've implemented TH functions to derive instances, and these instances in turn use things like fmap so they require context, and I want to produce instances that will not generate redundant constraint warnings.
I already made a simplifyContext :: [Pred] -> Q [Pred] helper to do this, but as this sounds to me like a common need, I expect this possibly already exists in some library but I've tried to find it and haven't. Or if it doesn't exist perhaps that's because there's a simpler technique that I'm missing..