[Haskell-cafe] MPTC inheritance - was operator error

Derek Gladding derek at solidmath.com
Tue Feb 24 14:33:13 EST 2009

Thanks to the kind replies I got off-list, I figured out that this was 
actually operator error on my part.

class (Node a, Edge b) => Graph a b

was actually

class (Node a, Edge b) => Graph g a b

but this was in code I'd written quite some time ago and I've written a 
lot of day-job C++ in the intervening period.

Main lesson learned: Read the ghc error message carefully, it contains 
all the information you need.

Thankyou once again.

- Derek

Derek Gladding 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