instances and modules

Feuer feuer@his.com
Mon, 31 Dec 2001 22:52:44 -0800


Some discussion has gone on recently regarding class methods that are
and are not passed across module boundaries.  One thing that struck me
as rather odd was that some/many/all people thought it was reasonable to
have

module M (C(a)) where
    class C t where
        a::...
        b::...
module N (.....) where
    import M
    instance C Int where
        a=.....

I don't understand how a type can be considered an instance of a class
if it doesn't provide all the methods of that class.  Why not make all
of these rules much simpler by requiring that a module N can contain an
instance declaration for class M.C if, and only if, M exports M.C(..)
and N imports M.C(..) (either qualified or unqualified)?  I don't see
why anyone would want to do something silly like
import qualified M as P(a)
import qualified M as Q(b)
but even if this is useful, I don't think it should be enough to allow
an instance declaration for C. The programmer should be required to
explicitly say
import qualified M as R(..)

IMVHO, it should not even be legal to have an instance declaration that
imports C(a,b), but that's just me.

David Feuer