Version française
Home     About     Download     Resources     Contact us    
Browse thread
Inter-module dependences
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Bobillot <damien.bobillot@m...>
Subject: Re: [Caml-list] Inter-module dependences [solved]

--Apple-Mail-4-958470366
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=ISO-8859-1;
	delsp=yes;
	format=flowed


Le 15 juin 05 =E0 17:39, Remi Vanicat a =E9crit :

> 2005/6/15, Damien Bobillot <damien.bobillot@m4x.org>:
>
>> I'm defining a graph structure compatible with the ocamlgraph =20
>> library.
>>
>> I want to be able to access all neighbors and edge to neighbors of a
>> vertex in 0(1), so I think I need to store the outgoing edge list of
>> each vertex in the vertex structure. I also need to be able to access
>> the source and destination of an edge in 0(1), so I store these
>> vertex in the edge structure.
>>
>> A standard Caml will be :
>>
>> type vertex =3D {
>>      label : int;
>>      out_edges : edge list;
>>      ...
>> } and edge =3D {
>>      label : int;
>>      src : vertex;
>>      dst : vertex;
>>      ...
>> }
>>
>> However, in ocamlgraph, the vertex and edge type must be defined by
>> modules of signatures (and I cannot modify it) :
>>
>> module type VERTEX =3D sig
>>      type t
>>      type label
>>      val create : label -> t
>>      val label : t -> label
>> end
>> module type EDGE =3D sig
>>      type t
>>      type label
>>      type vertex
>>      val create : vertex -> label -> vertex -> t
>>      val label : t -> label
>>      val src : t -> vertex
>>      val dst : t -> vertex
>> end
>>
>
> [...]
>
>
>> It works fine, but it doesn't respond to my problem : I want that V
>> use a type from E and at the same time E use a type of V.
>
> Why don't you do something like what follow ?
>
> type vertex =3D {
>       label : int;
>       out_edges : edge list;
>       ...
>  } and edge =3D {
>       label : int;
>       src : vertex;
>       dst : vertex;
>       ...
>  }
>
> module MyVertex : (VERTEX with t=3Dvertex and label=3Dint)=3D
> struct
>   type t=3Dvertex
>    ....
> end
>
> module MyEdge : (EDGE with t=3Dedge ...) =3D
> struct
>   type t =3D edge
>   ....
> end
>
> It should work with no problem.

Yes, it works !!!

Modules are powerful, but as every powerful things, it's hard to use =20
without a manual... (and I didn't found a good manual on the web, if =20
you know one I'll be interested).

Thank you very much

--=20
Damien Bobillot


--Apple-Mail-4-958470366
Content-Transfer-Encoding: base64
Content-Type: application/pkcs7-signature;
	name=smime.p7s
Content-Disposition: attachment;
	filename=smime.p7s

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIjCCAtsw
ggJEoAMCAQICAw54xzANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh
d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt
YWlsIElzc3VpbmcgQ0EwHhcNMDUwNDEzMTc1MTAxWhcNMDYwNDEzMTc1MTAxWjBJMR8wHQYDVQQD
ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSYwJAYJKoZIhvcNAQkBFhdkYW1pZW4uYm9iaWxsb3RA
bTR4Lm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ1TOYBqwJ42s0Fzz56jY1p0
fplGyikFgoNEUKGnOpqt4vpeoqUppAnORt2yvdQJxfIkhsWkrD/diiPS7MTF73wcxlSJtqYzVzPK
G/2WDm6dBinuWCIyWYFhtGedyxbap3kJW44H7cL7HUVVxZ0JhOIOTsjCoEzaeKnML7bctbIJeXEE
lErfbDv2jA1PDG1ru5dx+Q+AmbexX92ygnntE6aX3QZLSbhrytg4yCRdV8cOyQ9eFruZBI42RJv3
nJXevjUOr4n+y/7bzijAJj4BFyUU+dllvj6bmk5brnUXheCSOD0Ci20dqGNC1MyJ43b6MoIrbW7j
JwYIv12D6KuWoaUCAwEAAaM0MDIwIgYDVR0RBBswGYEXZGFtaWVuLmJvYmlsbG90QG00eC5vcmcw
DAYDVR0TAQH/BAIwADAN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