On Tue, Apr 8, 2008 at 11:05 PM, PR Stanley <[EMAIL PROTECTED]> wrote: > > > > > > > What is the difference between > > > > > > data T0 f a = MkT0 a > > > instance Eq (T0 f a) where ... > > > > > > and > > > > > > data T0 f a = MkT0 a > > > instance Eq a => Eq (T0 f a) where ... > > > > > The second one says that "TO f a" is only an instance of "Eq" if "a" is, > while the first says that "TO f a" is an instance regardless of the type of > its arguments. > > > > > More explanation please. :-) >
Well, it's similar with functions. If we try: foo :: a -> a -> Bool foo x y = x < y We'll get an error: the usage of `<` requires `a` to be in Ord class, which we write down as type signature: foo :: (Ord a) => a -> a -> Bool The similar effect is for type classes. Here: > instance Eq a => Eq (T0 f a) where ... We can see that we can compare elements of type `a` for equality. It's kind of saying: "if you give me an element of type `a`, and that type is in Eq class, I can tell you how to tell equality of elements of type T0 f a". Regards Christopher Skrzętnicki
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe