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=0.0 required=5.0 tests=none 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 BE322BBCA; Mon, 17 Mar 2008 11:21:44 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAGnj3UdREHVi/2dsb2JhbACmaA X-IronPort-AV: E=Sophos;i="4.25,512,1199660400"; d="scan'208";a="9555675" Received: from unknown (HELO office.stork.ru) ([81.16.117.98]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 Mar 2008 11:21:44 +0100 Received: from serp.office.stork.ru (serp [192.168.21.130]) by office.stork.ru (8.13.5/8.13.5) with ESMTP id m2HBfbLj012256; Mon, 17 Mar 2008 14:41:38 +0300 Message-ID: <47DE4635.7050101@stork.ru> Date: Mon, 17 Mar 2008 13:21:41 +0300 From: SerP User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Caml-list@yquem.inria.fr, caml-list-bounces Subject: Polymorphic method and polymorphic type Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; polymorphic:01 polymorphic:01 functions:01 int:01 int:01 expression:02 match:02 string:02 string:02 let:03 let:03 object:09 object:09 example:10 end:12 Simple example. All functions are fake. class getter = object method add_some p = p+1 end;; type 'a get_mode = [ `Read | `Watch of (#getter as 'a)];; let string_of_get_mode (gm: 'a get_mode) = match gm with `Read -> "Read" | `Watch g -> let i = g#add_some 1 in ("Watch "^ (string_of_int i));; class c = object method pgm : 'a. ('a get_mode) -> string = string_of_get_mode end;; -------------- This expression has type 'a. (#getter as 'a) get_mode -> string but is here used with type 'b. (#getter as 'b) get_mode -> string Type #getter as 'c = < add_some : int -> int; .. > is not compatible with type 'c ==================== Please help. Is it my error? how should we do that the right way?