[Haskell-cafe] MPTC inheritance
Derek Gladding
derek at solidmath.com
Tue Feb 24 13:09:12 EST 2009
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
More information about the Haskell-Cafe
mailing list