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 EA57E7F761 for ; Tue, 1 Dec 2015 10:42:35 +0100 (CET) IronPort-PHdr: 9a23:EI7cwxR/dee4I86lTCz43hHBadpsv+yvbD5Q0YIujvd0So/mwa65ZBaN2/xhgRfzUJnB7Loc0qyN4/2mCT1LuMzc+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8CVM1QD3WDgKZpJbzyI7izp/vEMhoVjLqtjgjDomVBvP9ps+GVzOFiIlAz97MrjtLRq8iBXpu5zv5UYCfayV+0CQLdZFDUrNXwurI2u7EGbDFjH2nxJeWUMkwFUBBDF2zFkUZrr+n/xtvB8wzWdJc2wTbc5Vjm4x7t2DRXlkiMGMXg1/TeEpNZ3ifd5qRm4uhFki6HdepuUO+dzNvfSdMkARGVcU+5UXjBBRIW1YIweBq8ce+9T6Yvl8Qhd5SCiDBWhUbu8ggRDgWX7iOhji7ws Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@mailhost.math.nagoya-u.ac.jp Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BEAAA4a11WlwWCBoVehH3ALIYPAoF5EQEBAQEBAQEBEAEBAQEBCBYHT4ItgggBAQQjBBkDATUBAQ4LGAICGA4CAlcGiECqYnGEaQKIDIQQAQEBAQEBAQMBAQEBAQEBAQETAQaBAYdjgm6EWYMcL4EVjhyIQI04gVuXFINyN4I9FgeBZWOFcQEBAQ X-IPAS-Result: A0BEAAA4a11WlwWCBoVehH3ALIYPAoF5EQEBAQEBAQEBEAEBAQEBCBYHT4ItgggBAQQjBBkDATUBAQ4LGAICGA4CAlcGiECqYnGEaQKIDIQQAQEBAQEBAQMBAQEBAQEBAQETAQaBAYdjgm6EWYMcL4EVjhyIQI04gVuXFINyN4I9FgeBZWOFcQEBAQ X-IronPort-AV: E=Sophos;i="5.20,368,1444687200"; d="scan'208";a="189853181" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 01 Dec 2015 10:42:33 +0100 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 616186442; Tue, 1 Dec 2015 18:42:31 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (rabbit-172.math.nagoya-u.ac.jp [172.16.254.254]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 091252524; Tue, 1 Dec 2015 18:42:31 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=5HU2hGYAEsl5lOHhwtImtzn7pcQ=; b=lrvuVNH+78j/TnqbpjjeOa54V6qh P83N2afkRJLM7aIEHDYi2ntl24bJLzOfmdz8vFBvdGLwwhBCc+1xbwLq/zX5LJI9 tDowmicbzx77LG8fu6TCjwObqy5byGWcggiv7P7+aLfmx8+N1URKWdLskzY69yRm 2wKGfGYoBjP4JKo= DomainKey-Signature: a=rsa-sha1; h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=XyXNex2ZSo7XrD018aEYxVdMBGdzxuXfvRuoF0h2qLANVQT3zRC5huZSF0FicOcOsJ1r8NcoH8WfX8xreppWfyQdBKu7YZ5erQiGNHPMaGCFuKdS6y/oxKOpqdzxcvAXY9jvyUusSTmfWOFrEtMCa9hEHzp/gAaO7O/s24sFWnc=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 50DEC6FC5; Tue, 1 Dec 2015 18:43:49 +0900 (JST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) From: Jacques Garrigue In-Reply-To: <565D690A.7000005@tu-berlin.de> Date: Tue, 1 Dec 2015 18:42:30 +0900 Cc: OCaML List Mailing Content-Transfer-Encoding: quoted-printable Message-Id: References: <565D690A.7000005@tu-berlin.de> To: =?utf-8?Q?Christoph_H=C3=B6ger?= X-Mailer: Apple Mail (2.3096.5) Subject: Re: [Caml-list] Constraint Inference of a poly-type variable in a class-method On 2015/12/01 18:31, Christoph H=C3=B6ger wrote: >=20 > Dear all, >=20 > As a way to work-around my latest scalability issues, I want to attach a > polymorphic method to a class with this functionality: >=20 > let f t =3D t#s > val f : < s : 'a; .. > -> 'a >=20 > I know I can write: >=20 > object method f =3D f end ;; >=20 > and >=20 > class x =3D object method f : 'a 'b . ( as 'b) -> 'a =3D f en= d ;; >=20 > However, the constraint might be somewhat larger, so I want it to be > inferred. Is there a way to have the compiler infer a constraint on a > poly-type variable? No. Basically, polymorphic method types cannot be compared, i.e. one type is no= t more general than another, so you always have to be explicit. This said, if your problem is that you might be calling more methods of t, = you can define a class type: class type [=E2=80=98a] t =3D object method s : =E2=80=98a end Then you can write method f : =E2=80=98a =E2=80=98b. (=E2=80=98a #t as =E2=80=98b) -> =E2=80= =98a =3D f Jacques Garrigue