[Haskell-cafe] Families of type classes
ostermann at informatik.tu-darmstadt.de
Sun Nov 6 11:30:21 EST 2005
Daniel Fischer schrieb:
> I'd prefer (very strongly) something like
> class Graph g n e | g -> n, g -> e where
> isConnectedTo :: g -> n -> e -> Bool -- or perhaps rather without "g"
> startNode, endNode :: e -> n
> . . . -- other Methods of interest like nodes, edges, components . . .
> with, e.g.
> instance Graph (Map node [node]) node (node,node) where . . .
Thanks for the suggestion. This looks good, but
it seems as if the "g" needs to occur in every signature, otherwise
the interpreter throws a "No instance for ... arising from ..."
error if you want to apply the function. Hence startNode would need to be
startNode :: g -> e -> n rather than startNode :: e -> n
Is there any way to get rid of this dummy argument?
More information about the Haskell-Cafe