Re: mutually recursive types and modules

From: Markus Mottl (
Date: Wed May 12 1999 - 20:04:56 MET DST

From: Markus Mottl <>
Message-Id: <>
Subject: Re: mutually recursive types and modules
To: (Andrew Kay)
Date: Wed, 12 May 1999 19:04:56 +0100 (MET DST)
In-Reply-To: <> from "Andrew Kay" at May 11, 99 05:32:17 pm

> 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:

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,,

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:22 MET