caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Andre Nathan <andre@digirati.com.br>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Mutually recursive types in different modules
Date: Mon, 14 Jul 2008 19:43:02 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0807141854070.14360@martin.ec.wink.com> (raw)
In-Reply-To: <1216054202.29061.2.camel@andre.mz.digirati.com.br>

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/


      parent reply	other threads:[~2008-07-14 17:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 16:50 Andre Nathan
2008-07-14 17:04 ` [Caml-list] " Jon Harrop
2008-07-14 17:50   ` Andre Nathan
2008-07-14 17:57   ` Arthur Chan
2008-07-14 18:04     ` Andre Nathan
2008-07-14 17:43 ` Martin Jambon [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=Pine.LNX.4.64.0807141854070.14360@martin.ec.wink.com \
    --to=martin.jambon@ens-lyon.org \
    --cc=andre@digirati.com.br \
    --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).