Is it possible to write a type function that would take a constraint like Show and return one that constrains the RHS to types that are not an instance of Show?
The signature would be something like
type family Invert (c :: * -> Constraint) :: * -> Constraint
No. It is a design principle of the language that you are never allowed to do this. The rule is if a program is valid, adding more
instances should not break it. This is the open-world assumption. Your desired constraint is a pretty direct violation:Would work, but adding
would break it. Therefore, the original program should never have been valid in the first place, and therefore
Invertcannot exist.