[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Haskell 1.3



Here is another suggestion for Haskell 1.3.

The current restriction that instances must be defined either in the class
module or the type module is painful.  If a module defining an abstract type
contains a class definition, it may be impossible to define an instance in the
module defining the type (eg, it may be pre-defined in the prelude) and to put
it in the module defining the class would be breaking into the abstraction
(the module may not be mine, and I may not have source access to it).  If the
only reason for the restriction is that instances don't have names to control
their import/export, I suggest dropping the restriction and allowing one or
both of the following forms for controlling export of instances:

   module M (... (==) ...) where
   instance Eq T where ...

   module M (... Eq(..) ...) where
   instance Eq T where ...

The first means "export all the instances of (==) defined in this module" and
the second means "export all the instances of the Eq methods defined in this
module" (allowed even though the module does not define the Eq class, but
merely extends it).  This doesn't allow separate instances to be
distinguished, but I can live with that; I don't want this to get heavy.

There would be an incompatibility with Haskell 1.2: if there is an explicit
export list, and the list does not mention a method/class, then instances of
that method/class are not exported.

Incidentally, I think the class and module systems both have some nasty
problems (eg Warren Burton's recent comments) and that both need a more
thorough redesign for Haskell 2.0.

Ian                                Ian.Holyer@uk.ac.bristol,   Tel: 0272 303334