AFAIK, there is currently no way to use DefaultSignatures with type families.
I see two options for doing what you want. Both have certain flaws, but maybe they are sufficient for your purposes.
Option 1: Use standard default type definitions
class Foo p where type Back p :: * type Back p = UnBar p type Forward p :: * type Forward p = ForwardBar (UnBar p) customFunc :: p -> IO ()
The UnBar helper type family is UnBar :
type family UnBar a :: * type instance UnBar (Bar a) = a
Then the instance could be simple:
instance Foo (Bar Bat) where customFunc _ = print "I am different customFunc and this is Bat Bat"
Option 2: Use Type Families Instead
class Foo p where customFunc :: p -> IO () type family Back p :: * type family Forward p :: *
Now we can give a general example for type families for all Bar types:
type instance Back (Bar a) = a type instance Forward (Bar a) = ForwardBar a
And more specific instances for the class, for specific Bar types:
instance Foo (Bar Bat) where customFunc _ = print "I am different customFunc and this is Bat Bat"
source share