[Haskell-cafe] Re: What do _you_ want to see in FGL?
Heinrich Apfelmus
apfelmus at quantentunnel.de
Tue May 18 05:07:01 EDT 2010
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
More information about the Haskell-Cafe
mailing list