caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ketti <kattlachan@gmail.com>
To: "Jacques Le Normand" <rathereasy@gmail.com>
Cc: "caml-list caml-list" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] mutually recursive modules
Date: Sun, 23 Mar 2008 19:37:52 +0100	[thread overview]
Message-ID: <6ebe51ce0803231137s75c16a30sce985f2de922b57@mail.gmail.com> (raw)
In-Reply-To: <f74178430803230959i4fe1090cx2cd2d7caccefa01f@mail.gmail.com>

2008/3/23 Jacques Le Normand <rathereasy@gmail.com>:
> how would I do that?
>

You have to factor out the types of the modules.
Lets say we have modules A and B which are mutually recursive.
A needs to know the signature of B and vise verse.

So we define the signatures somewhere visible to both A and B:

module type A_T = sig ... end
module type B_T = sig ... end

Now in A and B we can write something like this:

module MkA = functor (B: B_T) -> struct
  ...
end

And then we can tie it together in a third file:

module MkA = A.MkA
module MkB = B.MkB
module rec A : A_T = MkA(B)
and B : B_T = MkB(A)

Done. ^^ (unless i made mistakes)

Does someone know of a less cumbersome way?


  reply	other threads:[~2008-03-23 18:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-22 19:22 Jacques Le Normand
2008-03-22 19:37 ` [Caml-list] " Daniel Bünzli
2008-03-22 21:20   ` ketti
2008-03-23 16:59     ` Jacques Le Normand
2008-03-23 18:37       ` ketti [this message]
2008-03-24  9:21         ` rossberg
  -- strict thread matches above, loose matches on Subject: below --
2006-01-17  8:55 Brendan Miller
2006-01-17 10:21 ` [Caml-list] " Jacques Garrigue
2006-01-17 12:13   ` skaller
2005-12-02 10:15 Jonathan Roewen
2005-12-06 17:33 ` Alain Frisch

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=6ebe51ce0803231137s75c16a30sce985f2de922b57@mail.gmail.com \
    --to=kattlachan@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=rathereasy@gmail.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).