caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Bobillot <damien.bobillot@m4x.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Inter-module dependences [solved]
Date: Wed, 15 Jun 2005 18:15:06 +0200	[thread overview]
Message-ID: <A57AF0B2-0861-423D-B3CB-D432D7E9B149@m4x.org> (raw)
In-Reply-To: <6b8a9142050615083945b03312@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]


Le 15 juin 05 à 17:39, Remi Vanicat a écrit :

> 2005/6/15, Damien Bobillot <damien.bobillot@m4x.org>:
>
>> I'm defining a graph structure compatible with the ocamlgraph  
>> 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 = {
>>      label : int;
>>      out_edges : edge list;
>>      ...
>> } and edge = {
>>      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 = sig
>>      type t
>>      type label
>>      val create : label -> t
>>      val label : t -> label
>> end
>> module type EDGE = 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 = {
>       label : int;
>       out_edges : edge list;
>       ...
>  } and edge = {
>       label : int;
>       src : vertex;
>       dst : vertex;
>       ...
>  }
>
> module MyVertex : (VERTEX with t=vertex and label=int)=
> struct
>   type t=vertex
>    ....
> end
>
> module MyEdge : (EDGE with t=edge ...) =
> struct
>   type t = edge
>   ....
> end
>
> It should work with no problem.

Yes, it works !!!

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

Thank you very much

-- 
Damien Bobillot


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2375 bytes --]

      parent reply	other threads:[~2005-06-15 16:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15 14:12 Inter-module dependences Damien Bobillot
2005-06-15 15:01 ` [Caml-list] " Julien Signoles
2005-06-15 16:18   ` Damien Bobillot
     [not found] ` <6b8a9142050615083945b03312@mail.gmail.com>
2005-06-15 16:15   ` Damien Bobillot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A57AF0B2-0861-423D-B3CB-D432D7E9B149@m4x.org \
    --to=damien.bobillot@m4x.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).