Is it possible to specify that every member of a datakind satisfies a typeclass, such that the class constraint is implied? E.g.
data AB = A | B
class Foo (a :: AB) where get :: proxy a -> String
instance Foo A where get _ = "A"
instance Foo B where get _ = "B"
-- note lack of constraint here
get' :: proxy (a :: AB) -> String
get' = get
Basically a
is an AB
so we're sure there's an instance of Foo
for it.
I find it unlikely -- where is it going to get the Foo
dictionary? -- but I've seen some magic in my day.