From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 7EE157EFCD for ; Thu, 30 Oct 2014 16:19:53 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-50.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-50.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArECAOxWUlSDbwiWnGdsb2JhbABcvg8Gm04CgSQWAQEBAQERAQEBAQEICwkJFC6EAwEBBHkQCyElDwEESYhUBMQohWEBCgEBAR4Yhh6KWgeESwWfG5EGhjyBRIM3AQEB X-IPAS-Result: ArECAOxWUlSDbwiWnGdsb2JhbABcvg8Gm04CgSQWAQEBAQERAQEBAQEICwkJFC6EAwEBBHkQCyElDwEESYhUBMQohWEBCgEBAR4Yhh6KWgeESwWfG5EGhjyBRIM3AQEB X-IronPort-AV: E=Sophos;i="5.07,286,1413237600"; d="scan'208";a="85439696" Received: from ppsw-50.csi.cam.ac.uk ([131.111.8.150]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Oct 2014 16:19:40 +0100 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from host86-181-34-203.range86-181.btcentralplus.com ([86.181.34.203]:49285 helo=netbook) by ppsw-50.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:AES128-GCM-SHA256:128) id 1XjrVj-0003Wz-s8 (Exim 4.82_3-c0e5623) (return-path ); Thu, 30 Oct 2014 15:19:39 +0000 From: Leo White To: Philippe Veber Cc: caml users References: X-Face: "XWxb[u_Z\PA_Y?9@|IA!!+jTb(/290-*ea/Un$I0B98.$n%eL.;2w*,z]WR#T:,p[ NBd++M7l]#7zj7!{~iw $W-"/=|dVjhT[D{4~gE}gK<2`.6fs!;uqqud]vs2N/3^m7{aS1V, Date: Thu, 30 Oct 2014 15:19:39 +0000 In-Reply-To: (Philippe Veber's message of "Thu, 30 Oct 2014 15:51:35 +0100") Message-ID: <86y4rxfuus.fsf@cam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Caml-list] Typing of a parameterized class where the type parameter is the type of self. > # class type ['a] c = object ('a) method m : 'b end;; > class type ['a] c = object ('a) constraint 'a = < m : 'b. 'b; .. > method m : 'b end > > In particular I don't understand why the method m gets a polymorphic > type. To allow shorter type annotations for class types, OCaml tries to automatically turn methods with polymorphic types into polymorphic methods. In this case it is being a bit over eager and making your method polymorphic even though it doesn't need to. You can fix this by making it more obvious that your method's polymorphism is contained within the class parameter 'a. You can do this by writing in the constraint by hand: class type ['a] c = object ('a) constraint 'a = < m : 'b; ..> method m : 'b end Which now allows your type definition to work: # type 'a t = (< m : int ; .. > as 'a) c;; type 'a t = 'a c constraint 'a = < m : int > Regards, Leo