From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 61F8F7FCCB for ; Mon, 11 May 2015 01:19:54 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jacques.garrigue@gmail.com) identity=pra; client-ip=209.85.220.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jacques.garrigue@gmail.com"; x-sender="jacques.garrigue@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jacques.garrigue@gmail.com designates 209.85.220.46 as permitted sender) identity=mailfrom; client-ip=209.85.220.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jacques.garrigue@gmail.com"; x-sender="jacques.garrigue@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pa0-f46.google.com) identity=helo; client-ip=209.85.220.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jacques.garrigue@gmail.com"; x-sender="postmaster@mail-pa0-f46.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BeBgBt5k9VlC7cVdFchEGDHrJ1jl2HXYEeOhIBAQEBAQEBEQEBAQEHCwsJHzCEIQEBBBIRHQE4AQMMAQUFGAICGA4CAjQBBQEcBi4Hh3UDEQEFpyA+MYs4hGKITycNSIRKAQEBBwEBAQEBAQEVAQUOgROKGIRSgyIvgRYFizFpkQaVDTWBFVyDTWCCRgEBAQ X-IPAS-Result: A0BeBgBt5k9VlC7cVdFchEGDHrJ1jl2HXYEeOhIBAQEBAQEBEQEBAQEHCwsJHzCEIQEBBBIRHQE4AQMMAQUFGAICGA4CAjQBBQEcBi4Hh3UDEQEFpyA+MYs4hGKITycNSIRKAQEBBwEBAQEBAQEVAQUOgROKGIRSgyIvgRYFizFpkQaVDTWBFVyDTWCCRgEBAQ X-IronPort-AV: E=Sophos;i="5.13,403,1427752800"; d="scan'208";a="141884498" Received: from mail-pa0-f46.google.com ([209.85.220.46]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 11 May 2015 01:19:53 +0200 Received: by pacwv17 with SMTP id wv17so95078876pac.0 for ; Sun, 10 May 2015 16:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LrYoXfcNgI9wVadKaWpkOiBMEiyXgz+0/hRp58hh4e8=; b=UzJ4pAMgNBELiRLwsupSBfbLjzDoDnqi4HeoxzyHgz/in+KZRjVQ3KtlJO/vSkGKgV /xUH6NHPqeETNqzxjvr8MD0agmRWjeEvzyEwmMGQrqgq6JcUAHkguZxGvtmFK/SJRu2c n4R1h0a+yOFHmz3rGetNWmR0YVFeGrAxDpBZlLp1WGfzSzV8SYGSikUFFH0swn0bl10Y uw1RnGw6g0HfHcwHYDkGYP+my+oJb/Nkclk5o0K42kw1gKh+0y+8m4XwIhDlHfiNskbn JoWukkbxosS6IMaYscRPOnFLNitPp82q0n0FiF6567poIXLK1fx7efJ7CLnJ/mV7yRYK 4leg== X-Received: by 10.70.130.168 with SMTP id of8mr14467356pdb.131.1431299991739; Sun, 10 May 2015 16:19:51 -0700 (PDT) Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp. [58.158.128.157]) by mx.google.com with ESMTPSA id x2sm11123666pdm.40.2015.05.10.16.19.49 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 10 May 2015 16:19:50 -0700 (PDT) Sender: Jacques Garrigue Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) From: Jacques Garrigue In-Reply-To: Date: Mon, 11 May 2015 08:19:46 +0900 Cc: OCaML List Mailing Content-Transfer-Encoding: quoted-printable Message-Id: <836FDA54-2F58-4BC1-8E4E-12438240E03C@math.nagoya-u.ac.jp> References: To: Jordan W X-Mailer: Apple Mail (2.2098) Subject: Re: [Caml-list] Record fields not reexported from functors. On 2015/05/11 06:58, Jordan W wrote: >=20 > I believe there is an issue with record fields and functors. > It appears that while types are correctly exported from functors, the cor= responding record field scopes are not. Here is an example. >=20 > module type HasType =3D sig > type t > end >=20 > module EchoModule (Input:HasType): (HasType with type t =3D Input.t) = =3D (struct > type t =3D Input.t > end) >=20 > module ClonedModuleWithRecordType =3D EchoModule (struct > type t =3D {innerRecordField: int} > end) >=20 > (* This doesn't type check, but I can't see why it shouldn't. Record = fields' > scopes should be reexported just like the types themselves. >=20 > let myRecord: ClonedModuleWithRecordType.t =3D { > ClonedModuleWithRecordType.innerRecordField=3D10; > } There is a misunderstanding here: the declaration =E2=80=9Ctype t =3D Input= .t=E2=80=9D does not re-export Input.t, it just defines a type abbreviation pointing to Input.t. A type abbreviation does not contain field information. You should qualify the field name with the original module name; unfortunat= ely there is no such module here since you defined the module inline. Here is the type you get for ClonedModuleWithRecordType: module ClonedModuleWithRecordType : sig type t end Since there is no module to refer to, all information about the type is los= t. The solution is to properly define the module argument: module MyRecord =3D struct type t =3D {innerRecordField: int} end module ClonedModuleWithRecordType =3D EchoModule (MyRecord) =E2=80=A6 {MyRecord.innerRecordField =3D 10 } =E2=80=A6 which gives you: module ClonedModuleWithRecordType : sig type t =3D MyRecord.t end Note that since 4.02 you can also omit the module name when the type is kno= wn. But again, this will only work if there is a module name. Jacques Garrigue=