Ian Holyer writes:

   The current restriction that instances must be defined either in
   the class module or the type module is painful.

LISTEN TO THIS MAN!  Trying to use the module system in (what we
imagined to be) a sensible way on the Glasgow Haskell compiler [which
is written in Haskell] has been a nightmare.  Take a pile of
mutually-dependent modules, add the "instance virus" [instances go
with the class or type, and you can't stop them...], and you have
semi-chaos.  All attempts to have export/import lists that "show
what's going on" have been undermined by having to add piles of cruft
to keep instancery happy.

I would go for either of the following not-thought-through choices:

* Instances travel with the *type*, not the class.  99% of the time,
  this is what we want.  If your instance isn't going, add an explicit
  export of the type constructor.  Possibly have a special case for
  instances of user-defined classes for Prelude types...

* Make it so that imported instances whose class/type is out-of-scope
  may be silently ignored (i.e., an exception to the closure rule).

  For example, if I write "import Foo" and Foo's interface includes
  "instance Wibble Wobble" and none of my "imports" happen to bring
  "Wibble" (or "Wobble") into scope, then a compiler may drop this
  instance silently.  It is not an error.  (Of course, if you try to
  *use* such an instance, you will get an error downstream.)

Of course, something that involves new syntax/extra machinery would
also be fine.

Will

PS: Get rid of "default" declarations, too.  No-one uses them. (Hi,
Kevin!)

Reply via email to