From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 0C8C17EE25 for ; Fri, 1 Nov 2013 00:43:11 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwBAB3qclKFBoIFnGdsb2JhbABZDocOvF+BOQ4BAQEBAQgUCTyCJQEBBAEjIAE1AgMLCQIaAhgOAgJXBhOIAQWOMppodoNjAoVjiQ0HgSmNczMHgms1gQ6JQY5MlHBO X-IPAS-Result: AuwBAB3qclKFBoIFnGdsb2JhbABZDocOvF+BOQ4BAQEBAQgUCTyCJQEBBAEjIAE1AgMLCQIaAhgOAgJXBhOIAQWOMppodoNjAoVjiQ0HgSmNczMHgms1gQ6JQY5MlHBO X-IronPort-AV: E=Sophos;i="4.93,613,1378850400"; d="scan'208";a="40059008" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 01 Nov 2013 00:42:50 +0100 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 416B063A1; Fri, 1 Nov 2013 08:43:05 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id EDA5540D0; Fri, 1 Nov 2013 08:43:04 +0900 (JST) DomainKey-Signature: h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=; c=nofws; d=math.nagoya-u.ac.jp; q=; s=alpha Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 9D9D239AD; Fri, 1 Nov 2013 08:43:04 +0900 (JST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1816\)) From: Jacques Garrigue In-Reply-To: Date: Fri, 1 Nov 2013 08:43:03 +0900 Cc: caml-list Content-Transfer-Encoding: quoted-printable Message-Id: <98AF3DB4-B0DF-4958-9283-39E849520B29@math.nagoya-u.ac.jp> References: To: Nicolas Ojeda Bar X-Mailer: Apple Mail (2.1816) Subject: Re: [Caml-list] recursive types and modules problem 2013/11/01 5:13=E3=80=81Nicolas Ojeda Bar =E3= =81=AE=E3=83=A1=E3=83=BC=E3=83=AB=EF=BC=9A > What is the best way to rewrite the following recursive definitions so th= at > I can actually compile them? >=20 > S =3D Set.Make (struct type t =3D t1 let compare x1 x2 =3D x1.stamp - x2.= stamp end) >=20 > type t1 =3D { > stamp : int; > x : t2 > } >=20 > and t2 =3D { > y : S.t > } A slightly shorter version, using the fact that recursive modules containin= g only types require no implementation: module rec T : sig type t1 =3D { stamp: int; x: t2 } and t2 =3D { y: S.t } end =3D T and S : Set.S with type elt =3D T.t1 =3D Set.Make (struct open T type t =3D t1 let compare x1 x2 =3D x1.stamp - x2.stamp = end) Jacques Garrigue