Magicloud Magiclouds wrote: > So I think I got what you guys meant, I limited ClassB to only H. > Then how to archive my requirement, that from and to only return items > that instanced ClassB?
If you are willing to go beyond Haskell98 (or Haskell2010), you can use a multi-parameter class. Enable the extension: {-# LANGUAGE MultiParamTypeClasses #-} An then, instead of class (ClassA a) => ClassC a where from :: (ClassB b) => a -> [b] to :: (ClassB c) => a -> [c] you say class (ClassA a, ClassB b) => ClassC a b c where from :: c -> [b] to :: c -> [a] This means that for each triple of concrete types (a,b,c) that you wish to be an instance of ClassC, you must provide an instance declaration, e.g. instance ClassC Test H H where from = ...whatever... to = ...whatever... Now you have the fixed type H in the instance declaration and not a universally quantified type variable. Cheers Ben _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe