[Haskell-cafe] MPTC inheritance

Lennart Augustsson lennart at augustsson.net
Tue Feb 24 14:00:35 EST 2009


There's nothing wrong with the definition of FooGraph.  That's how you do it.

  -- Lennart

On Tue, Feb 24, 2009 at 6:09 PM, Derek Gladding <derek at solidmath.com> wrote:
> Please forgive me if I'm still mentally contaminated by the OO way of seeing
> (and discussing) the universe, but I'm trying to figure out how to "inherit
> an interface" from a multi-parameter type class.
>
> I have a Graph class that's parameterisable by Node and Edge type:
>
> class (Node a, Edge b) => Graph a b where
>    (lots of stuff that you can do with Graph a b)
>
> Now, I'd like to build a FooGraph on top of this that adds additional
> capabilities:
>
> class (Graph a b) => FooGraph a b where
>    (lots of additional stuff)
>
> but this isn't allowed (kind mismatch).
>
> Of couse, I can do:
>
> class (Node a, Edge b) => FooGraph a b
>
> but this means that I have to manually replicate the Graph a b operations in
> the FooGraph a b class definition, which is (a) work that the machine should
> (?) be able to do for me, and (b) fragile.
>
> Any pointers / wisdom would be very much appreciated.
>
> - Derek
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list