Modeling multiple inheritance

Brandon Michael Moore brandon at its.caltech.edu
Wed Sep 24 20:02:32 EDT 2003


On Thu, 25 Sep 2003 ozone at algorithm.com.au wrote:

> On 25/09/2003, at 7:22 AM, Brandon Michael Moore wrote:
>
> > I'm trying to build a nicer interface over the one generated by
> > jvm-bridge. I'm using fancy type classes to remove the need to mangle
> > method names. I would like methods to be automatcially inherited,
> > following an inheritance hierarcy defined with another set of type
> > classes.
> ...
>
> Hi Brandon, it looks like the way that you're modelling inheritance and
> OO-style overloading is basically the same way that I did in my thesis:
>
>      http://www.algorithm.com.au/mocha
>
> The actual implementation of the thesis will be up in CVS in ~24 hours,
> I'm just waiting from an email back from the people I'm getting it
> hosted with.
>
> If you want a quick run-down on how I did the OO-style overloading
> without delving into the paper, let me know and I'll post a quick
> summary.  I've only skimmed your email, but I think that the problem
> you're having with interfaces is solved with the way I'm modelling OO
> overloading and class inheritance.

Thanks. I think I could use the summary. I already found and skimmed your
thesis, and I don't think it gives me exactly what I want. All you do in
chapter 3 is represent a multiple inheritance hierarcy. I want default
instances that will propagate method definitions along the hierarcy. I'm
not sure that's possible though.

I want something like this:

data Object
data ClassA
data ClassB
data ClassC

class SubClass super sub <???>

instance SubClass Object ClassA
instance SubClass Object ClassB
instance SubClass ClassA ClassC
instance SubClass ClassB ClassC

class HasFooMethod cls args result  <??>
  foo :: cls -> args -> result
instance SubClass super sub, HasFooMethod super args result ,???
         => HasFooMethod sub args result where
  foo obj args = foo (upCast obj) args

instance HasFooMethod Object int int where
  foo = id
(now all four classes have a foo method)

Brandon



More information about the Haskell-Cafe mailing list