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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Mutually recursive types in different modules
On Mon, 14 Jul 2008, Andre Nathan wrote:

> Hello
>
> Say I have the following type definition:
>
>  type a = { x: int; foo: b } and  b = { y: int; bar: a }
>
> Is it possible to define types a and b in their own files (thus in
> modules A and B) and still allow them to be mutually recursive?

No.
The usual way to proceed is to use one file for the type definitions and 
as many files as you want for the implementation.

If after that you want to make the types abstract for external use, you 
can use the -pack option of ocamlc or ocamlopt. It lets you define a 
super module with its own .mli file.


Martin

--
http://wink.com/profile/mjambon
http://mjambon.com/