From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 33476BBAF for ; Sat, 28 Aug 2010 21:34:55 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.56,284,1280700000"; d="scan'208";a="57924090" Received: from mail-qw0-f54.google.com ([209.85.216.54]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 28 Aug 2010 21:34:54 +0200 Received: by qwg5 with SMTP id 5so4871689qwg.27 for ; Sat, 28 Aug 2010 12:34:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.222.6 with SMTP id ie6mr1726572qcb.28.1283023903253; Sat, 28 Aug 2010 12:31:43 -0700 (PDT) Received: by 10.229.181.69 with HTTP; Sat, 28 Aug 2010 12:31:43 -0700 (PDT) In-Reply-To: References: Date: Sat, 28 Aug 2010 21:31:43 +0200 Message-ID: Subject: Re: [Caml-list] Defining a type and a module type recursively From: Kaustuv Chaudhuri To: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; buenzli:01 recursive:01 sig:01 struct:01 sig:01 struct:01 28,:98 wrote:01 rec:01 encode:01 recursively:01 recursively:01 caml-list:01 int:01 int:01 On Sat, Aug 28, 2010 at 10:30 AM, Daniel B=C3=BCnzli wrote: > Is it possible to define a type and a module type recursively ? Technically, you can use recusive modules to encode all kinds of recursive type definitions. Here, for example, is your case: module rec M : sig type 'a t =3D 'a * (module N.T) end =3D struct type 'a t =3D 'a * (module N.T) end and N : sig module type T =3D sig type s =3D S of int M.t end end =3D struct module type T =3D sig type s =3D S of int M.t end end type 'a t =3D 'a M.t module type T =3D N.T It's pretty ugly. Please only use such patterns if you have solid reasons not to go with something simpler. -- Kaustuv