Is it possible to specify a type class constraint that must be satisfied by all instances of a type family?
For example, given the following declaration, how would I ens
Is this what you are looking for?
{-# LANGUAGE FlexibleContexts, TypeFamilies, FlexibleInstances #-}
-- Data family inside a class so that we can add an extra Eq constraint
class Eq (Channel c) => MyClass c where
data Channel c :: *
-- A simple toy instance
instance MyClass Int where
data Channel Int = CI Int deriving Eq
-- A more complex instance with separate Eq instance
instance MyClass Char where
data Channel Char = CC Char
instance Eq (Channel Char) where
(CC x) == (CC y) = x == y