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 7EC9F7F778 for ; Fri, 13 May 2016 11:26:27 +0200 (CEST) IronPort-PHdr: 9a23:FbCj4Rx4vNBRD5jXCy+O+j09IxM/srCxBDY+r6Qd0OkTIJqq85mqBkHD//Il1AaPBtWKragdwLKM+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuSt+U1Z38j7r60qaQSjsLrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYeVcyDAgD1uSmxHh+pX4p8Y7oGx48sgs/M9YUKj8Y79wDfkBVGxnYCgJ45jCsRDCS0Oh/HoHWWVexhNMCgnDqh/gX4z6sgP+u/p81ijcNsrzG/R8Ez+r6qMuTB7zlA8GMSQ4+SfZkIY42KlSpRbkox1k36bVZpuUPbxwZPWOU8kdQD8LZcFcWDBbBZv4J64OBOoIMOIS5934plAOpBa6QxKrCezz0DhQrn7wwaA+le8mFFeVj0QbA9sSvSGM/53OP6AIXLXwlfGQwA== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=michael.soegtrop@intel.com; spf=Pass smtp.mailfrom=michael.soegtrop@intel.com; spf=None smtp.helo=postmaster@mga04.intel.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of michael.soegtrop@intel.com) identity=pra; client-ip=192.55.52.120; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="michael.soegtrop@intel.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of michael.soegtrop@intel.com designates 192.55.52.120 as permitted sender) identity=mailfrom; client-ip=192.55.52.120; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="michael.soegtrop@intel.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@mga04.intel.com) identity=helo; client-ip=192.55.52.120; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="postmaster@mga04.intel.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D4AACtnDVXkHg0N8BehA1+BrlggXYahXoCgTA6EgEBAQEBAQEBEQEBAQEHDQkJIS+CLYIVAQEBBDoPPAQCAQgRBAEBCxQJBzIUCQgBAQQBEgiIJgG/BAEBAQEBAQEDAQEBAQEBAQEBAR2GJoRMhEGDKYIuBZgiBQGdNo9BJwOCPBIKgUtuh1sBfgEBAQ X-IPAS-Result: A0D4AACtnDVXkHg0N8BehA1+BrlggXYahXoCgTA6EgEBAQEBAQEBEQEBAQEHDQkJIS+CLYIVAQEBBDoPPAQCAQgRBAEBCxQJBzIUCQgBAQQBEgiIJgG/BAEBAQEBAQEDAQEBAQEBAQEBAR2GJoRMhEGDKYIuBZgiBQGdNo9BJwOCPBIKgUtuh1sBfgEBAQ X-IronPort-AV: E=Sophos;i="5.24,613,1454972400"; d="scan'208";a="218143694" Received: from mga04.intel.com ([192.55.52.120]) by mail2-smtp-roc.national.inria.fr with ESMTP; 13 May 2016 11:26:26 +0200 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 13 May 2016 02:26:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,613,1455004800"; d="scan'208";a="975618170" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by orsmga002.jf.intel.com with ESMTP; 13 May 2016 02:26:24 -0700 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by IRSMSX107.ger.corp.intel.com (163.33.3.99) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 13 May 2016 10:26:23 +0100 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.35]) by irsmsx112.ger.corp.intel.com ([169.254.1.10]) with mapi id 14.03.0248.002; Fri, 13 May 2016 10:26:23 +0100 From: "Soegtrop, Michael" To: Alain Frisch , "caml-list@inria.fr" Thread-Topic: [Caml-list] Specify the default hash function for a type Thread-Index: AdGs7HCGm9QdbZDXQnOXFTEowCMUzwAAdzOAAAJfb0A= Date: Fri, 13 May 2016 09:26:22 +0000 Message-ID: <0F7D3B1B3C4B894D824F5B822E3E5A172CEF175C@IRSMSX102.ger.corp.intel.com> References: <0F7D3B1B3C4B894D824F5B822E3E5A172CEF1630@IRSMSX102.ger.corp.intel.com> <850765ff-25f1-ecb9-9707-74d3dc47675c@lexifi.com> In-Reply-To: <850765ff-25f1-ecb9-9707-74d3dc47675c@lexifi.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Specify the default hash function for a type Dear Alain, this are temptations on Friday morning ... I guess as a beginner I should r= esist, not be lazy, and write the hash function by hand. But I put it into = appendix D of my OCaml notes ;-) Best regards, Michael > -----Original Message----- > From: Alain Frisch [mailto:alain.frisch@lexifi.com] > Sent: Friday, May 13, 2016 11:06 AM > To: Soegtrop, Michael; caml-list@inria.fr > Subject: Re: [Caml-list] Specify the default hash function for a type >=20 > Dear Michael, >=20 > Don't tell anybody (ahem), but the following might work depending on your > exact use case... >=20 > If you define a type such as: >=20 > type t =3D { > foo: ....; > id: int; > } >=20 > and if you set the tag of values for this type to Obj.record_tag (=3D 248= ) with > Obj.set_tag, then polymorphic hash *and* comparison functions will use the > "id" field and ignore the "foo" field (and any other extra fields). It is > important to keep "id" as the second field to mimic the layout of real ob= ject > values (and exception slots). >=20 > In particular, this lets you easily "forget" sub-parts of a value (by set= ting "id" > to a fixed constant), or implement "references compared with physical > equality" (use a counter to assign unique "id" to each such reference). >=20 >=20 > Best regards, >=20 > Alain Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928