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 439707F042 for ; Fri, 18 Dec 2015 10:18:47 +0100 (CET) IronPort-PHdr: 9a23:k1G5khLxlZeMbkfJT9mcpTZWNBhigK39O0sv0rFitYgUL/rxwZ3uMQTl6Ol3ixeRBMOAu6wC07KempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+lRMiK14ye7KObxd76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKKx8zGJsIk+PzV6nvp/jtM0rzyMFsPsk84ZdSqjgZOxsRrVdCHEiMnspzMztrxjKCwWVsCgySGITxzFIGQne8BbiXqDRLCT3rKIp0ymAPNbqSqg0HzSl4qhmUjf0lWINOiQ98WeRhsEm3/ETmw6ouxEqm92cW4qSLvcrJq4= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=christoph.hoeger@tu-berlin.de; spf=None smtp.mailfrom=christoph.hoeger@tu-berlin.de; spf=None smtp.helo=postmaster@mail.tu-berlin.de Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=pra; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=mailfrom; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.tu-berlin.de) identity=helo; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="postmaster@mail.tu-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BvAADfznNWnCEHlYJdhHm/UodGOxEBAQEBAQEBARABAQEBAQgLCQkhLoItgjEECwFFNgIFFgsCCwMCAQIBPwwNBgIBAYgrBJtIj3CSJoEBkkqBSQWWf5ZtlAE4gXYBCwFQgV5xhREBAQE X-IPAS-Result: A0BvAADfznNWnCEHlYJdhHm/UodGOxEBAQEBAQEBARABAQEBAQgLCQkhLoItgjEECwFFNgIFFgsCCwMCAQIBPwwNBgIBAYgrBJtIj3CSJoEBkkqBSQWWf5ZtlAE4gXYBCwFQgV5xhREBAQE X-IronPort-AV: E=Sophos;i="5.20,445,1444687200"; d="scan'208";a="157559771" Received: from mail.tu-berlin.de ([130.149.7.33]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2015 10:18:44 +0100 X-tubIT-Incoming-IP: 91.66.95.158 Received: from ip5b425f9e.dynamic.kabel-deutschland.de ([91.66.95.158] helo=[192.168.178.42]) by mail.tu-berlin.de (exim-4.76/mailfrontend-6) with esmtpsa [UNKNOWN:AES128-SHA:128] for id 1a9rBS-0000I9-5V; Fri, 18 Dec 2015 10:18:43 +0100 To: caml users From: =?UTF-8?Q?Christoph_H=c3=b6ger?= Organization: =?UTF-8?Q?Technische_Universit=c3=a4t_Berlin?= Message-ID: <5673CF72.4030808@tu-berlin.de> Date: Fri, 18 Dec 2015 10:18:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.12.18.90917 X-PMX-Spam: Gauge=IIIIIII, Probability=0%, Report='' Subject: [Caml-list] polymorphic methods Dear all, I am attempting to store polymorphic methods in classes (i.e. keep the type variables out of the class-type by putting them directly into the method signatures). However, I have some trouble when it comes to convince the compiler that my code is typecorrect: type ('a, 'b) f_arg = < x : 'b; .. > as 'a ;; let f : 'a 'b . (('a,'b) f_arg) -> 'b = fun a -> a#x ;; class foo = object method f : 'a 'b . ('a, 'b) f_arg -> 'b = f end ;; yields: Error: This expression has type 'a 'b. (< x : 'b; .. > as 'a) -> 'b but an expression was expected of type 'c 'b. (< x : 'b; .. > as 'c) -> 'b The type variable 'd occurs inside 'd What is 'd? Why do these types not unify? -- Christoph Höger Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin Tel.: +49 (30) 314-24890 E-Mail: christoph.hoeger@tu-berlin.de