From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id BFDEBBBAF for ; Thu, 10 Sep 2009 17:01:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArAAAFqxqEoSBwdQkWdsb2JhbACbPgEBAQEJCwoHEwWyaodSiEmEGAU X-IronPort-AV: E=Sophos;i="4.44,364,1249250400"; d="sig'?scan'208";a="35823550" Received: from biscayne-one-station.mit.edu ([18.7.7.80]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Sep 2009 17:01:04 +0200 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.13.6/8.9.2) with ESMTP id n8AF0hVJ009440 for ; Thu, 10 Sep 2009 11:00:43 -0400 (EDT) Received: from CSR-DYN-53.MIT.EDU (CSR-DYN-53.MIT.EDU [18.75.3.53]) (authenticated bits=0) (User authenticated as farr@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id n8AF0gh3015311 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Thu, 10 Sep 2009 11:00:43 -0400 (EDT) Message-Id: From: Will M Farr To: caml-list@inria.fr Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-3--590271519" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: A (Silly?) Question About Universal Type Quantification Date: Thu, 10 Sep 2009 11:00:35 -0400 X-Pgp-Agent: GPGMail 1.2.0 (v56) X-Mailer: Apple Mail (2.936) X-Scanned-By: MIMEDefang 2.42 X-Spam: no; 0.00; pervasives:01 functor:01 struct:01 forall:01 struct:01 forall:01 functor:01 designation:98 unbound:01 polymorphic:01 polymorphic:01 int:01 data:02 data:02 argument:02 X-Attachments: type="application/pgp-signature" name="PGP.sig" name="PGP.sig" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-3--590271519 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hello, I recently encountered a situation where I had (effectively) the following polymorphic type: type 'a record = { id : int; data : 'a } and the following compare function let compare {id = id1} {id = id2} = Pervasives.compare id1 id2 and wanted to put such records into a set. However, I could not figure out how to make the polymorphic 'a in the type definition "disappear" in the module argument to the Set.Make functor. For example, the obvious Set.Make(struct type t = 'a record let compare = compare end) fails because the 'a in the type definition for t is unbound. Is there no way to do this? I'm thinking of some sort of "forall" designation, which universally quantifies the type parameter, like Set.Make(struct type t = forall 'a : 'a record let compare = compare end) (I'm sure that there is better terminology for this---please pardon my ignorance about types and type theory.) I ended up solving my problem by placing the record type into a functor, whose argument specified the concrete type for data, but I'm curious if other solutions exist. Thanks, Will --Apple-Mail-3--590271519 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.12 (Darwin) iEYEARECAAYFAkqpFJkACgkQ1IoZbWY+dGw05wCfbtZhq0N0Slh95wwTc2Mq38Wr bSsAoMensTM/RcxjnO6lQE1k9s51uZAx =jCCg -----END PGP SIGNATURE----- --Apple-Mail-3--590271519--