On Tue, 14 Dec 2004 15:40:13 +0000, Keith Wansbrough <[EMAIL PROTECTED]> wrote: > > On the other hand, it's difficult or impossible to make a list of a > > bunch of different types of things that have nothing in common save > > being members of the class. > > I've recently been playing with making, for each class C, a > "interface" datatype IC (appropriately universally and existentially > qualified so as to include a dictionary for class C), and then making > this IC an instance of class C. Then I can wrap any instance of C up > in an IC, and make a list of those. >
I think there should be standard syntax for this... Some sort of operator for turning one or several type classes into an interface datatype. So you could write something like something like... f :: <Show,Num> -> [<Show,Eq>] -> <Eq,Num> f a xs = ... So the first parameter is just a value of the interface datatype data ShowNum = forall a . (Show a, Num a) => ShowNum a And it's all automatically up and downcasted. This is one of the more powerful idioms in languages such as Java (collections of objects which satisfy some interface, for instance) and should, IMO, be supported by some special syntax to facilitate it's use in Haskell. /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe