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.5 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B42B9BBC1 for ; Sun, 23 Mar 2008 19:37:54 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqACAKJA5kdA6aazc2dsb2JhbACRFwEMAwQFCRSRFYNI X-IronPort-AV: E=Sophos;i="4.25,543,1199660400"; d="scan'208";a="24105371" Received: from py-out-1112.google.com ([64.233.166.179]) by mail4-smtp-sop.national.inria.fr with ESMTP; 23 Mar 2008 19:37:54 +0100 Received: by py-out-1112.google.com with SMTP id a73so1360516pye.33 for ; Sun, 23 Mar 2008 11:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=cOjA/UNOc28gzUqFDHJlQ83iiddRoD8KMTD3+1n86qI=; b=CNycr6Si1yMsTyP/AJHVc1CiPQmQTT1JD0oR6DZv5gwQGw7BrDOmpxwxiCbxNRza2AL+D9lcPOlpK2SWwDbMlg7TfCH7aVdjdy9yyAmmTE26KYSkF0NOHKrjUPMUFqaLdVSlEowFZwGeRzoGbSSk/OuBE6UO1RB2SHMTlRrp2/A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=XSea2IdarKZ682yht5LtWyVnFSNhqES4CorWWKN8X3herKawUR04Zt9MnL8oXyXqs65UC9qo+Jwl1FyBsmIuzeWThz1PZ4U3jbvscD29B1Waxo2Hn6gVxUdX8k8o1THbNdnkWfJjFrnvODB1C1taYj0NxxeO7tyaRz9dcQki4r8= Received: by 10.114.190.6 with SMTP id n6mr10077235waf.51.1206297472853; Sun, 23 Mar 2008 11:37:52 -0700 (PDT) Received: by 10.114.60.12 with HTTP; Sun, 23 Mar 2008 11:37:52 -0700 (PDT) Message-ID: <6ebe51ce0803231137s75c16a30sce985f2de922b57@mail.gmail.com> Date: Sun, 23 Mar 2008 19:37:52 +0100 From: ketti To: "Jacques Le Normand" Subject: Re: [Caml-list] mutually recursive modules Cc: "caml-list caml-list" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7B22B0CF-8E65-434A-9EF7-0C20EBE618E8@erratique.ch> <6ebe51ce0803221420h272bec70ne92695651f6b2b38@mail.gmail.com> X-Spam: no; 0.00; recursive:01 recursive:01 sig:01 sig:01 functor:01 struct:01 rec:01 signatures:01 caml-list:01 define:02 modules:02 modules:02 module:03 module:03 jacques:03 2008/3/23 Jacques Le Normand : > 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?