On Sunday 16 October 2011, 20:03:02, Patrick Browne wrote: > Hi, > Does the subclass relation have any meaning when two classes > have instances with the same type? > I get the same results from Listing 1 and Listing 2 below. > Regards, > Pat
The only effect of a superclass constraint is that you can't make a type an instance of the subclass without a superclass instance for the type in scope. Usually, a superclass constraint means there is a connection between the methods of both classes (like for Eq/Ord), and then it is expected that the instances respect that connection, but the compiler can't enforce that. In your example, the only difference is that with the superclass constraint foo :: House h => h -> Integer foo h = addressB h + addressH h works, while without superclass constraint, foo would need both classes in its context. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
