I suppose what I want is impossible without Template Haskell but I\'ll ask anyway.
I have an interface for types like Data.Set and Data.IntSet
You can write this:
class (SetLike (EfficientSet a), Elem (EfficientSet a) ~ a) =>
HasEfficientSet a where
type EfficientSet a
If you associate the Elem type family with the SetLike class, you probably wouldn't even need the SetLike superclass constraint:
class SetLike s where
type Elem s
insert :: Elem s -> s -> s
member :: Elem s -> s -> Bool
class Elem (EfficientSet a) ~ a => HasEfficientSet a where
type EfficientSet a