Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: mutually recursive types and modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: mutually recursive types and modules
> So far so good.  Next we realised that we don't care about the order of
> edges in the edge list, and we are always converting edge lists into sets
> to do union operations and so on, so we decided to recode the node type
> with edges as sets for efficiency (which is very important here).
> 
> * type node = {
> *             node_id : int;
> *             mutable edges : NodeSet.t;
> *             ... (other fields)
> * 	      }
> 
> At this point the world seemed to spin and make me dizzy, because we can't
> defined NodeSet without node, and we can't define node without NodeSet.
> I can't see any way to express this in OCaml.

Unfortunately, there is no way to do this (yet). You might want to take
a look at the following thread in the archive of the OCAML-mailing-list,
where Xavier Leroy explains the problem:

  http://pauillac.inria.fr/caml/caml-list/0896.html

In my case it was the combination of classes and modules in a recursive
way, which also doesn't work.

There is no short workaround. I solved my problem by redesigning the
system so that it does not require mutual recursive definitions - it's
ok, but not as elegant as it could have been without this restriction.

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl