Kevin,

| In case you have not figured out a couple of months ago I posted the
| beginnings of a generic container and algorithm collection for
| Haskell.  Duren the process of doing that I discovered the many
| limitations of Haskell current type system.  I simply could not do what
| I wanted to do in Haskell with out resorting to hideously complex
| types.  The biggest thing that was biting be was all the ambiguity
| caused from using multiple parameter classes.

I posted details about a new way to avoid these kinds of problems on
the Haskell list a few weeks ago by annotating class declarations with
information about "functional dependencies" between class parameters.
In case you missed it, here is a repeat of the web pointer:

   http://www.cse.ogi.edu/~mpj/fds.html

This extension has been implemented in Hugs 98 (and, for the most part,
in GHC), and seems to work well in practice.  The code fragment that
you posted for MArray was not complete, but I believe that your intentions
could probably be captured using something like the following:

  class MArray monad mutArray | mutArray -> monad where
    newArray :: Int -> monad (mutArray st el)
    ...

Other interpretations would also be possible if you wanted to include
the index and element types as class parameters.

Other examples that you might want to consider, based on your messages
from several months ago, include:

  class Collection container element | container -> element where ...
  class Dictionary dict index element | dict -> index, element where ...

etc.

Please take a look at the web page above for more details.  You will
be able to play with the implementation very soon.

All the best,
Mark




Reply via email to