| Is this legal Haskell 98 Code:
| 
| module Test where
| 
| class A a where
|   foo :: a -> a
| 
| class (A a) => B a where
|   boo :: a -> a
| 
|   foo a = a
| 
| GHC compiles it just fine but the latest vesion of Hugs98 gives me
|   ERROR "test.hs" (line 10): No member "foo" in class "B"
| 
| So I was wondering if giving default definitions for base member in a
| derived class is legal is Haskell 98.

No, I don't think it is.  See page 45 of the report for the details.

| If it is not legal is it a
| proposed extension that Hugs will eventually support?

There aren't any plans to support this kind of thing.  In fact it's
not exactly clear what the semantics for examples like this should
be.  Would you allow the definitions of classes A and B to be
in separate modules?  And would that mean that different defaults
might be applied in different modules?  If so, that would almost
certainly break the coherence property that is required to ensure
that overloading has a well-defined meaning.

I wonder what semantics GHC uses here, and how it is implemented.
Or perhaps it just treats the definition of foo as a local definition
with a scope that is restricted to the body of the second class
declaration.

All the best,
Mark



Reply via email to