You can do it using a trick of Oleg's, which even has its own library on hackage
By heavily abusing the type class system, it is possible to generate a fundep
class TypeEq a b result | a b -> result
such that TypeEq a b True
only when a~b
, and TypeEq a b False
otherwise
so you can write
instance (TypeEq () a False) => T a
and I think that should work. I should be clear, this type equality test is pure evil in how it is implemented, but it does mostly work. Check out the code for that library if you want to understand how this works/generalize it (also read the HList paper).
If it is at all possible to do what you want to do without negative constraint, do that instead.