Ivan Lazar Miljenovic wrote: > Heinrich Apfelmus writes: >> Ivan Lazar Miljenovic wrote: >>> >>> Well, we'll provide a Map-based one that lets you specify the vertex >>> type as a type parameter; this functionality (type parameter being ued >>> for the vertex type) won't be required since not all graphs will be able >>> to chop and choose which vertex type to use. >> >> Ah, that would indeed make it easy. Maybe make the map based graph >> generic, so that it can be used with any primitive graph implementation? >> >> data VertexGraph node gr a b = VG (gr a b) (BiMap node (Vertex gr)) >> >> instance (Ord node, Graph gr) => Graph VertexGraph node gr where > > Not sure I understand what the point of the `gr' is there; what I meant > was something like: > > newtype MapGraph node a b = MG (Map node (Map node b, a, Map node b))
Yes; what I mean is that you can retrofit a custom vertex type to any graph implementation that uses a fixed vertex type. So, let's say that data Gr a b = .. -- graph with vertex type Vertex Gr = Int then type Gr' node a b = CustomVertex node Gr a b data CustomVertex node gr a b = CV (gr a b) (Map node (Vertex gr)) is a graph with custom vertex type node . Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe