From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id E1679BB84 for ; Mon, 14 Jul 2008 19:47:17 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAHwte0jAXQIn/2dsb2JhbACrQA X-IronPort-AV: E=Sophos;i="4.30,360,1212357600"; d="scan'208";a="13104220" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Jul 2008 19:47:17 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m6EHlHpA001708 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 14 Jul 2008 19:47:17 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An0AALcte0hCbwQcmmdsb2JhbACSLgEBAQEBCAUIBxEEmF8 X-IronPort-AV: E=Sophos;i="4.30,360,1212357600"; d="scan'208";a="15100315" Received: from out4.smtp.messagingengine.com ([66.111.4.28]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Jul 2008 19:47:16 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 38EC713A744; Mon, 14 Jul 2008 13:47:15 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 14 Jul 2008 13:47:15 -0400 X-Sasl-enc: v1u+Kdrs7+adkTVgDMAvNI8iqlN7fEZHLEwzX5memzZX 1216057634 Received: from [192.168.1.10] (ALyon-157-1-62-228.w81-251.abo.wanadoo.fr [81.251.29.228]) by mail.messagingengine.com (Postfix) with ESMTPSA id A4A3C19082; Mon, 14 Jul 2008 13:47:13 -0400 (EDT) Date: Mon, 14 Jul 2008 19:43:02 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: Andre Nathan Cc: caml-list@inria.fr Subject: Re: [Caml-list] Mutually recursive types in different modules In-Reply-To: <1216054202.29061.2.camel@andre.mz.digirati.com.br> Message-ID: References: <1216054202.29061.2.camel@andre.mz.digirati.com.br> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 487B9125.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 recursive:01 foo:01 recursive:01 -pack:01 ocamlc:01 ocamlopt:01 mli:01 nathan:98 wrote:01 abstract:01 caml-list:01 int:01 int:01 jambon:01 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/