caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Arthur Chan" <baguasquirrel@gmail.com>
To: "Jon Harrop" <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Mutually recursive types in different modules
Date: Mon, 14 Jul 2008 10:57:36 -0700	[thread overview]
Message-ID: <74cabd9e0807141057u64b31518h49627afb30de5503@mail.gmail.com> (raw)
In-Reply-To: <200807141804.32640.jon@ffconsultancy.com>

[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]

As Jon demonstrates it is "possible," but I do not think it truly achieves
what you are trying to do.  What is your use case?  I do not recommend
trying to make types recursive across modules.  Even recursively defined
modules have reared their ugly end on me.  It is equivalent to writing
non-orthogonal code, in the functional paradigm (see Pragmatic Programmer).



On Mon, Jul 14, 2008 at 10:04 AM, Jon Harrop <jon@ffconsultancy.com> wrote:

> On Monday 14 July 2008 17:50:02 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?
>
> Yes. See the OCaml Journal article "Tricks with recursion: knots, modules
> and
> polymorphism" or Google for the phrase "untying the recursive knot".
>
> --
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/products/?e
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
-----------------------------------------------------------------------
(\__/)
(='.'=)This is Bunny. Copy and paste Bunny into your
(")_(")signature to help him gain world domination.
------------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 2480 bytes --]

  parent reply	other threads:[~2008-07-14 17:57 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 [this message]
2008-07-14 18:04     ` Andre Nathan
2008-07-14 17:43 ` Martin Jambon

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=74cabd9e0807141057u64b31518h49627afb30de5503@mail.gmail.com \
    --to=baguasquirrel@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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).