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 43CAE7F778 for ; Fri, 13 May 2016 10:13:56 +0200 (CEST) IronPort-PHdr: 9a23:TV7PoxEHrOcwB43JhhY3451GYnF86YWxBRYc798ds5kLTJ75rsmwAkXT6L1XgUPTWs2DsrQf27uQ6firADZYqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7H0ocWYOl8QzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqLcQzarEAbX2oKiB1QR0Dg7Rr6V5r1+GOus+t22CCXOYvtSr07RS6l949qTgPljGEMMDtvo0/Njcklpq9d6DegoxhgxInYKNWfMft6erzaet8yR2NHU91NTSFMHsW3aI5ZXLlJBvpRs4So/whGlhC5HwT5Qbq3kjI= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=bmillwood@janestreet.com; spf=Pass smtp.mailfrom=bmillwood@janestreet.com; spf=None smtp.helo=postmaster@mxout3.mail.janestreet.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of bmillwood@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of bmillwood@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.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@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AFAQAJjDVXiuXIaSZegmyBIX4GuWGBdhqFegKBKQc5EwEBAQEBAQEBEQEBAQgWCVCCLYIWAQEDARIRHQEBBzABBAsLBAc3AgIiEgEFARwGExsHiAUIA6AVgTE+MYpUZ4RBAQEFjDEBAQEBAQEBAQEBAQEBAQEBAQEBAQEUCBCGFYRNhAuDNIJZjleJVY4ejxmOAxIegQ4iAoI2DBIKgVhhiFoBAQE X-IPAS-Result: A0AFAQAJjDVXiuXIaSZegmyBIX4GuWGBdhqFegKBKQc5EwEBAQEBAQEBEQEBAQgWCVCCLYIWAQEDARIRHQEBBzABBAsLBAc3AgIiEgEFARwGExsHiAUIA6AVgTE+MYpUZ4RBAQEFjDEBAQEBAQEBAQEBAQEBAQEBAQEBAQEUCBCGFYRNhAuDNIJZjleJVY4ejxmOAxIegQ4iAoI2DBIKgVhhiFoBAQE X-IronPort-AV: E=Sophos;i="5.24,613,1454972400"; d="scan'208,217";a="177685051" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2016 10:13:55 +0200 Received: from tot-qpr-mailcore2.delacy.com ([172.27.56.106] helo=tot-qpr-mailcore2) by mxout3.mail.janestreet.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1b18EL-0000TH-A7 for caml-list@inria.fr; Fri, 13 May 2016 04:13:53 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore2 with JS-mailcore (0.1) (envelope-from ) id BXNYzB-AAAAas-Ig; 2016-05-13 04:13:53.273569-04:00 Received: from mail-ig0-f198.google.com ([209.85.213.198]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1b18EL-0002Jj-6g for caml-list@inria.fr; Fri, 13 May 2016 04:13:53 -0400 Received: by mail-ig0-f198.google.com with SMTP id sq19so21151578igc.0 for ; Fri, 13 May 2016 01:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=45ZsIEaRiMPLxZFKYP2T9V1EwiWsjh59BtSCOnwSk/0=; b=dRPD6o1zSKkDBs6yKdBpAX4LSV25v7RRBK2Mmtf+7VxQAGI5xsIl308wH6OroLUM89 snmceoZYeH0cKOw/LYunwaFLV34nPRbIYF2d7E6mT8DOi0aDsnxiKA/ZxAzdB7c+CgWf s+Z/IGs3FWkRYo/v3bweQLnEVh7m428FUJX+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=45ZsIEaRiMPLxZFKYP2T9V1EwiWsjh59BtSCOnwSk/0=; b=NPDbDElRgNlKdE5G/dEwu3VbRQo6oltAsQDUcKc+cgRsXGTfgo2Aar0J7FlAqs5cs3 EfcBW10RA3rpx/dskj1N0yR4MwHo8k2yCIplA6U+E9CYBQb5e2sZhzEsOM+hsKqQpmZ1 DK4Vc1jzostFnlnxRaeBKhgH9T1bfKtri+KONf+0ZU8BQGvWeAnSY1dEgoDUil9o5MRk uhoC5+nJPUnRdVvpx9nNMCK/1RhCn1JbWTlIhKTVraDLLlRma3mYFJIKEN5tyGlwzMrd XpX1Pj/6NHBJ+Ee943YBZxRcW29ubrZ/73AvBXTm/1fKpT9UnPSf8GXUZlk+QuS0tnbP zevw== X-Gm-Message-State: AOPr4FVIBagFtxkBxgw7M4aHCf8mDGEfBJ1GNvmwE2cvGUPPeQh9JF9+4rXPz8O9WeANzSBZTkCYQ9SpyCPcMJjPki6LgXtTzlRJQkDlNzIuTZ2LXIma6LFTIN1shDEMgSYKqKFpBvoHFH5qrcDNw/O2UPmBYfeaZPQ2CSWDGMo= X-Received: by 10.202.60.84 with SMTP id j81mr8281961oia.196.1463127232878; Fri, 13 May 2016 01:13:52 -0700 (PDT) X-Received: by 10.202.60.84 with SMTP id j81mr8281955oia.196.1463127232715; Fri, 13 May 2016 01:13:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.35.8 with HTTP; Fri, 13 May 2016 01:13:33 -0700 (PDT) In-Reply-To: <0F7D3B1B3C4B894D824F5B822E3E5A172CEF1630@IRSMSX102.ger.corp.intel.com> References: <0F7D3B1B3C4B894D824F5B822E3E5A172CEF1630@IRSMSX102.ger.corp.intel.com> From:Ben Millwood Date: Fri, 13 May 2016 16:13:33 +0800 Message-ID: To:"Soegtrop, Michael" Cc:"caml-list@inria.fr" Content-Type: multipart/alternative; boundary=001a113cc78cf7be480532b4dae6 X-JS-Processed-by: mailcore X-Sender-Copy: hkg-copy Subject: Re: [Caml-list] Specify the default hash function for a type --001a113cc78cf7be480532b4dae6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Polymorphic hash operates without type information, so it's not able to tell that it's hashing your record type vs. some other type with the same structure. So I would guess that what you want is not possible. The Core team is working on a ppx extension analogous to ppx_sexp_conv and ppx_compare which generates hash functions automatically, and would make this kind of thing possible, but it's not done yet. On 13 May 2016 at 15:52, Soegtrop, Michael wrote: > Dear Ocaml Users, > > > > I wonder if there is a way to specify a default hash function for a type, > which is then used by the automated hash functions e.g. created for recor= ds > containing this type. I have e.g. a record with about 10 fields and I am > happy with the default hash functions for most fields and for the record, > but for just one field I would like to use a custom hash function, but I > don=E2=80=99t want to write a hash function for the record. > > > > I am currently using the standard library, but if there is a solution with > Batteries or Core, I would also be interested. > > > > Best regards, > > > > Michael > > 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 > --001a113cc78cf7be480532b4dae6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Polymorphic hash operates without type information, so it&= #39;s not able to tell that it's hashing your record type vs. some othe= r type with the same structure. So I would guess that what you want is not = possible.

The Core team is working on a ppx extension an= alogous to ppx_sexp_conv and ppx_compare which generates hash functions aut= omatically, and would make this kind of thing possible, but it's not do= ne yet.

On 13 May 2016 at 15:52, Soegtrop, Michael <michael.soegtrop@i= ntel.com> wrote:

Dear Ocaml Users,

=C2=A0

I wonder if there is a way to specify a default hash= function for a type, which is then used by the automated hash functions e.= g. created for records containing this type. I have e.g. a record with abou= t 10 fields and I am happy with the default hash functions for most fields and for the record, but for just on= e field I would like to use a custom hash function, but I don=E2=80=99t wan= t to write a hash function for the record.

=C2=A0

I am currently using the standard library, but if th= ere is a solution with Batteries or Core, I would also be interested.

=C2=A0

Best regards,

=C2=A0

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, ww= w.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


--001a113cc78cf7be480532b4dae6--