I'm trying to define a pair of class instances inductively. That is:
class Foo a b | a -> b where
foo :: a -> b
instance (not?)Foo a => Bar a b
foo x = ...
instance Foo a => Bar a b
foo x = ...
The first instances determines the base action, and the seconds recursively calls foo. Is there any way to do this? A good example would be flattening a list, where in the first case it's the identity function and in the second it's a recursive application of concat.