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 ACA497F736 for ; Wed, 16 Sep 2015 14:26:46 +0200 (CEST) IronPort-PHdr: 9a23:9YvTvRZTtvtapv4QUGUtVM7/LSx+4OfEezUN459isYplN5qZpci4bnLW6fgltlLVR4KTs6sC0LqK9fqxEjBfqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7z0ocyYP1oArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIYTGZn9Kq8xSLgdCDU9L0g04tfqvF/NV1ih/HwZB1kWkxBBHgzZpCrnTJ73tCay4vZ92W+BIN//S7Y5cTun5qZvDhTvjXFUZHYC7GjLh5ko3+pgqxW7qkknzg== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=thi.suzanne@gmail.com; spf=Pass smtp.mailfrom=thi.suzanne@gmail.com; spf=None smtp.helo=postmaster@mail-wi0-f173.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of thi.suzanne@gmail.com) identity=pra; client-ip=209.85.212.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="thi.suzanne@gmail.com"; x-sender="thi.suzanne@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of thi.suzanne@gmail.com designates 209.85.212.173 as permitted sender) identity=mailfrom; client-ip=209.85.212.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="thi.suzanne@gmail.com"; x-sender="thi.suzanne@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-wi0-f173.google.com) identity=helo; client-ip=209.85.212.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="thi.suzanne@gmail.com"; x-sender="postmaster@mail-wi0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CmBwD9XvlVm63UVdFdg3dpsUqLXwEBgXuGAQKBQD0PAQEBAQEBAQEQAQEBAQEGCwsJIS6CHYIHAQEEEhEECwEFCAEbHAIDDAYFCw8CBRYLAgIJAwIBAgEREQEFARwTCAEBHod2AQMSBAGnOYEwPjGLRoFsgnmKJAoZJw1WhAwBAQgCARkBBQ6BFIVRhH2EWjoXglKBQwEElV6FEIdzghOGXRCQRDWBFzkBAQGCK4F/b4oqAQEB X-IPAS-Result: A0CmBwD9XvlVm63UVdFdg3dpsUqLXwEBgXuGAQKBQD0PAQEBAQEBAQEQAQEBAQEGCwsJIS6CHYIHAQEEEhEECwEFCAEbHAIDDAYFCw8CBRYLAgIJAwIBAgEREQEFARwTCAEBHod2AQMSBAGnOYEwPjGLRoFsgnmKJAoZJw1WhAwBAQgCARkBBQ6BFIVRhH2EWjoXglKBQwEElV6FEIdzghOGXRCQRDWBFzkBAQGCK4F/b4oqAQEB X-IronPort-AV: E=Sophos;i="5.17,539,1437429600"; d="scan'208";a="147477084" Received: from mail-wi0-f173.google.com ([209.85.212.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 16 Sep 2015 14:26:46 +0200 Received: by wicfx3 with SMTP id fx3so68010923wic.0 for ; Wed, 16 Sep 2015 05:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=0PNbCj1Or3yg9gCK4F2bJt+J1Tr1YoNbYOL1A/0pbwU=; b=nHiIA96ZLS1hpDbQzzQ1qDnhqUyFIZYD9iwYc7PTLIOhPOGLNP5lofiAXLERPitapg 5SEkZtP/Kvu7rGriKw5DyajDdvzb5zScSX/LRfg9Dq8Po2fnZVKGfQILo8xJypKi1OPW KPbtBTFcwRi6Yf/s956WlpPbgpAP2Ceds4bEvpEpFISmaEe9EdIHakuiBxsi+xfdHL7V yvBPlAWzZfH/LkTg75LcSbnBqsYDxiS9q97RVsycOKDhSALdMium0mVi8wpfaV9X7Y/e Tcp+7X9liBpnfxNhHtVa8scCZnzRNwrZmKoO6rLjERj2wcsisyxACkCV9/HprbGgzdx5 vgNA== X-Received: by 10.181.13.102 with SMTP id ex6mr18458202wid.64.1442406405688; Wed, 16 Sep 2015 05:26:45 -0700 (PDT) Received: from [192.168.1.7] (89-92-99-210.hfc.dyn.abo.bbox.fr. [89.92.99.210]) by smtp.googlemail.com with ESMTPSA id uo6sm26323719wjc.1.2015.09.16.05.26.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2015 05:26:44 -0700 (PDT) To: caml-list@inria.fr References: <55F95E5E.6000209@gmail.com> From: Thibault Suzanne Message-ID: <55F96004.4010001@gmail.com> Date: Wed, 16 Sep 2015 14:26:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55F95E5E.6000209@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] Pattern matching of records There is no need to specify the origin module in front of each field : match s0 with | { S.a = 0; b = 0 } -> true | _ -> false Le 16/09/2015 14:19, Leonardo Laguna Ruiz a écrit : > > I have the following type > > (* File: S.ml *) > module S = struct > type s = > { > a : int; > b : int; > } > end > > > I I have found that for creating records I can do as follows: > > (* File: main.ml *) > open S > let s0 = S.{ a = 0; b = 0} > > > However this does not work for pattern matching: > > (* this does not work *) > match s0 with > | S.{ a = 0 ; b = 0 } -> true > | _ -> false > > > These two alternatives work, but one with a warning and the other > (depending on the type) is too verbose: > > (* this produces a warning *) > match s0 with > | { a = 0 ; b = 0 } -> true > | _ -> false > > (* this works *) > match s0 with > | { S.a = 0 ; S.b = 0 } -> true > | _ -> false > > > Is there any other way of writing pattern matches as compact as S.{ a > = 0 ; b = 0 } ? (which is consistent to the construction of the same > value) > > I know that it's possible to do: > > let open S in > match s0 with > | { a = 0 ; b = 0 } -> true > | _ -> false > > but the main reason I don't do it is because I have more records like: > > match s0,k0 with > | { S.a = 0 }, {K.a = 0 } -> true > > > > Best regards, > > Leonardo > > >