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 B41417F736 for ; Wed, 16 Sep 2015 14:19:44 +0200 (CEST) IronPort-PHdr: 9a23:YNxUhRxdkLhsLznXCy+O+j09IxM/srCxBDY+r6Qd0ewSIJqq85mqBkHD//Il1AaPBtWHragVwLaJ+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuStKU1ZX8i7/60qaQSjsLrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYeVcyDAgD1uSmxHh+pX4p8Y7oGwD884mooRLWKD+OqA5VqBwDTI8Mmlz6teh/U3IRA6Lo38dSXk+kxxSAgGD4gusDbnrtS6vkud63iCAMcq+abk7RDKrp512SQ2g3CIAOzo390nYj8VxiORQpxf39E83+JLdfIzAbKk2RajaZ95PHWc= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=modlfo@gmail.com; spf=Pass smtp.mailfrom=modlfo@gmail.com; spf=None smtp.helo=postmaster@mail-ig0-f177.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of modlfo@gmail.com) identity=pra; client-ip=209.85.213.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="modlfo@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of modlfo@gmail.com designates 209.85.213.177 as permitted sender) identity=mailfrom; client-ip=209.85.213.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="modlfo@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-ig0-f177.google.com) identity=helo; client-ip=209.85.213.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="postmaster@mail-ig0-f177.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DjDADVXflVm7HVVdFdg3dpqQoLBogvi2IBAQiBcIdDPg4BAQEBAQEBARABAQEBAQYLCwkhIwuCHYIfEQQRCAEbHAIDEhAPAgUWCwILAwIBAgEREQEFASINCAEBHod2AQMSBAGlOoIFgTA+MYtGgWyCeYokChknDVaEMgEFDoEUhQqNQYFDAQSVXnaEGodzghOGXRCQRDWBFz4BAQEDgWmCOW+KKgEBAQ X-IPAS-Result: A0DjDADVXflVm7HVVdFdg3dpqQoLBogvi2IBAQiBcIdDPg4BAQEBAQEBARABAQEBAQYLCwkhIwuCHYIfEQQRCAEbHAIDEhAPAgUWCwILAwIBAgEREQEFASINCAEBHod2AQMSBAGlOoIFgTA+MYtGgWyCeYokChknDVaEMgEFDoEUhQqNQYFDAQSVXnaEGodzghOGXRCQRDWBFz4BAQEDgWmCOW+KKgEBAQ X-IronPort-AV: E=Sophos;i="5.17,539,1437429600"; d="scan'208";a="147476135" Received: from mail-ig0-f177.google.com ([209.85.213.177]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 16 Sep 2015 14:19:43 +0200 Received: by igcpb10 with SMTP id pb10so33709293igc.1 for ; Wed, 16 Sep 2015 05:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=xSz0pP1usqs4K8pdOWPaWjUSCScCr9ZRY4nn9hrvEi4=; b=Be2OLTzakXwKIP/vE1w4hlWeeC6w63rVP6wevCT6Mc0rKotYd7Zax0w2md2uYukC9v FIedze4al9ZI5StkrWckOT1eDq+fVv6P0+9EHmw0PTnDzNPl7sZLnUh3jLqFlHOz7jj5 4JxmzVTblU02RUlp6sOr0XbWP4oR6Lb0yHa83HKBrP4OOCr2SS/qnItiR2L90gOfKdqZ 9JTCfJYVRgU4qTPM6Sd5OBejz/Go4uFzLc0ZK+l6LjvBdD0NSH2YYOWtB1pR2It9KXX2 BUsg++Tk8padDBL/hC+jyH2pi0Cm3cw8HNEjNhbdmQvDve/K5yX6lelCuhvPA8DE5ggI Ltjg== X-Received: by 10.50.20.8 with SMTP id j8mr14783996ige.36.1442405982244; Wed, 16 Sep 2015 05:19:42 -0700 (PDT) Received: from [10.10.156.106] ([94.136.92.222]) by smtp.googlemail.com with ESMTPSA id z27sm10219698ioi.36.2015.09.16.05.19.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2015 05:19:41 -0700 (PDT) To: "caml-list@inria.fr" From: Leonardo Laguna Ruiz Message-ID: <55F95E5E.6000209@gmail.com> Date: Wed, 16 Sep 2015 14:19:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] Pattern matching of records 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