On 08-Feb-2001, Dylan Thurston <[EMAIL PROTECTED]> wrote:
> On Thu, Feb 08, 2001 at 09:41:56PM +1100, Fergus Henderson wrote:
> > One point that needs to be  resolved is the interaction with default methods.
> > Consider
> > 
> >         class foo a where
> >                 f :: ...
> >             f = ...
> >                 f2 :: ...
> >             f2 = ...
> > 
> >         class (foo a) => bar a where
> >                 b :: ...
> >  
> >         instance bar T where
> >             -- no definitions for f or f2
> >             b = 42
> > 
> > Should this define an instance for `foo T'?
> > (I think not.)
> 
> Whyever not?

Because too much Haskell code uses classes where the methods are
defined in terms of each other:

        class Foo a where
                -- you should define either f or f2
                f :: ...
                f = ... f2 ...
                f2 :: ...
                f2 = ... f ...

> Because there is no textual mention of class Foo in the
> instance for Bar?

Right, and because allowing the compiler to automatically generate
instances for class Foo without the programmer having considered
whether those instances are OK is too dangerous.

> Think about the case of a superclass with no methods;
> wouldn't you want to allow automatic instances in this case?

Yes.

I think Marcin has a better idea: 

| So maybe there should be a way to specify that default definitions
| are cyclic and some of them must be defined?

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to