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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 18C2A82355 for ; Tue, 23 Jan 2018 17:05:50 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=yallop@gmail.com; spf=Pass smtp.mailfrom=yallop@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f172.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=209.85.223.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 209.85.223.172 as permitted sender) identity=mailfrom; client-ip=209.85.223.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f172.google.com) identity=helo; client-ip=209.85.223.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-io0-f172.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A0GZWPxOv07hF7xV9lTIl6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0LfnyrarrMEGX3/hxlliBBdydt6odzbKO+4nbGkU4qa6bt34DdJEeHzQksu?= =?us-ascii?q?4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1?= =?us-ascii?q?Ov71GonPhMiryuy+4ZLebxlViDanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPde?= =?us-ascii?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0ozE5z+yG9htXk4DEkqFSC66eICNWvNKYyWXcJc4z240?= =?us-ascii?q?EIO5Qopk7imA8Q/3z709cLjR8ywc8JPkjJ17vrKJ0x418jNwAoKW1GTfF2w=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AOBADtW2dahqzfVdFeHAEBAQQBAQoBA?= =?us-ascii?q?YUcJweDVpkJggKEAYYEjTmCFwqFOwKEbwcZBwQyFgEBAQEBAQEBAQEBEgEBAQg?= =?us-ascii?q?LCwgoL4I4JAGCRgEBAQMBIwQZARseAwELBgULDQICJgICIgERAQUBHAYBEoocA?= =?us-ascii?q?QMNCKV4QIwTgW0YBQEcgwsFg2UKGScNWYIPAQEIAQEBARwCBhJ9gzuCFYZtgy8?= =?us-ascii?q?EhQaCZQWjfotEihmUI5c8FAUggRcmAYIBMxoIGxU9MoF4gkUfgXNBN4pzAQEB?= X-IPAS-Result: =?us-ascii?q?A0AOBADtW2dahqzfVdFeHAEBAQQBAQoBAYUcJweDVpkJggK?= =?us-ascii?q?EAYYEjTmCFwqFOwKEbwcZBwQyFgEBAQEBAQEBAQEBEgEBAQgLCwgoL4I4JAGCR?= =?us-ascii?q?gEBAQMBIwQZARseAwELBgULDQICJgICIgERAQUBHAYBEoocAQMNCKV4QIwTgW0?= =?us-ascii?q?YBQEcgwsFg2UKGScNWYIPAQEIAQEBARwCBhJ9gzuCFYZtgy8EhQaCZQWjfotEi?= =?us-ascii?q?hmUI5c8FAUggRcmAYIBMxoIGxU9MoF4gkUfgXNBN4pzAQEB?= X-IronPort-AV: E=Sophos;i="5.46,402,1511823600"; d="scan'208";a="252214311" Received: from mail-io0-f172.google.com ([209.85.223.172]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 23 Jan 2018 17:05:48 +0100 Received: by mail-io0-f172.google.com with SMTP id 72so1438961iom.10 for ; Tue, 23 Jan 2018 08:05:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=/2US//9b03eM/QPPDsJdJLI4/xdzxVTXCo1r4Pi3470=; b=jMAe+qWq1UNChVQ8/3MdRRKEg41RLCnM2CeBJI4d/PWtQ16axMxOGNazHnoqj643QR c0ATJDyJNmrppyjSG9H0qw86TtsSk1YSSLM5XEAyOo2EC2NPk9BfijMqegM89m911QVo KKtC7/UOkfOcGignQzFkFUkk/W5bzQw6XgTN0lG8Vm4uPAjdRtjVHLvqgX/6qCagOwYX 7vqfOptaxMdlbv5HVwF/pqSrliDnAGVvOgFm+I+gSoYK3JGCmG4VoXToXqUw4q7rBTMu VkCGDuyOpWj/hYZ0LMF2/ANbNS1VaIuE2yJSKSXl/7IZt7sfCPNJSz/FxPoRGwWH5T4Q SuLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=/2US//9b03eM/QPPDsJdJLI4/xdzxVTXCo1r4Pi3470=; b=NhnouvqcscDg+/Xs4ZazqYKnLvCRI9w1Q4F1lDDkcoIJCQyqpGM/djFejjZo9TyydS q+MTHjj5VgklndCdsWOGfSaLITUv4RaXPLi6WO0WNiKrSxm8zULd/W5Ww8vyiHJ4/6WC PFZES8lWLc+gK03yHmqZbHasCCwcgRVAr2ntm/oQEkSk9eK5bLxslpRVv6Y188JTarI4 YDF0vNhvorRGmorELuHCcsoCG3uvgpXb0TLBoiZlJVENZfI1nkkbp9Q0HgzROQYwKlhX XYRDjvfSTd/dwXAmT/3u5d5kDSStla3jfcMmhswg3JOgQ+Yz3EJZE3Vlj1qWT+9Way9P VBSQ== X-Gm-Message-State: AKwxytdEFBjSSSz9JDNK8kHYttBXXp7jEh6T1hQv4Og8mBmWygs8aHLo xj28p5Z4r3UUSXFGb6fY0oyXwVp03gYzK51OiNbOOg== X-Google-Smtp-Source: AH8x227SiHh/W2NAGJM3mcJnzpHSXZFDQAUI/EMGqafJqZHVo52GPKvTHf23dt5gF1+k5pyumHK9Rr9n4ougdxFphew= X-Received: by 10.107.36.195 with SMTP id k186mr4176701iok.131.1516723547288; Tue, 23 Jan 2018 08:05:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.83.131 with HTTP; Tue, 23 Jan 2018 08:05:46 -0800 (PST) In-Reply-To: <20180123145453.GA1916@Magus.localnet> References: <20180123145453.GA1916@Magus.localnet> From: Jeremy Yallop Date: Tue, 23 Jan 2018 16:05:46 +0000 Message-ID: To: Oleg , Caml List Content-Type: text/plain; charset="UTF-8" Subject: Re: [Caml-list] Are record types generative? On 23 January 2018 at 14:54, Oleg wrote: > Although both M2 and S are two instances of m2, and hence both > S.v and M2.v should have the record type t = {l:int}, they are not > regarded equal. Yes: record definitions are indeed generative in OCaml, unlike in Standard ML. > The problem is easy to fix: > > module F3(S:m2 with type t = M2.t) = struct > let res = S.v = M2.v > end > ;; > > module F3 : > functor (S : sig type t = M2.t = { l : int; } val v : t end) -> > sig val res : bool end > > let _ = let module M = F3(M2) in M.res;; > > but even in this simple case the fix is ugly (and becomes uglier in > the real code). Maybe there is a way to avoid adding too many sharing > constraints? One approach is to ensure that record and variant declarations do not appear in signatures, so that type members in signatures are just equations that refer to top-level types. Then your example could be written like this: type s = {l:int} module type m2 = sig type t = s val v : t end module M2 : m2 = struct type t = s let v = {l=1} end module F2(S:m2) = struct let res = S.v = M2.v end Things become a little trickier if the type definition refers to other elements in the signature module type m3 = sig type a type t = {l:a} ... Losing equalities between different instances of 't' may in fact be the desired behaviour here, since 'a' can be instantiated differently in each implementation of the module. But if it's important to keep equalities then parameterising the record can help: type 'b s = {l:'b} module type m3 = sig type a type t = a s ... > BTW, the new manual has a section about common polymorphism > pitfalls. Modules also have a fair share of dark corners (along with > the objects). Perhaps there could be a section in the manual about > not so obvious aspects of modules (in the first approximation, > just collecting questions and answers like the present one). I think that'd be very useful.