From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id BCB11BB81 for ; Fri, 17 Feb 2006 22:53:54 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1HLrrxw026960 for ; Fri, 17 Feb 2006 22:53:54 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA04737 for ; Fri, 17 Feb 2006 22:53:53 +0100 (MET) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.191]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1HLrqOY026955 for ; Fri, 17 Feb 2006 22:53:53 +0100 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1FADXu-0008E5-00; Fri, 17 Feb 2006 22:53:46 +0100 Received: from [84.58.149.40] (helo=gate.lan.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1FADXu-0003l6-00; Fri, 17 Feb 2006 22:53:46 +0100 Received: from flakew.lan.gerd-stolpmann.de (flakew.lan.gerd-stolpmann.de [192.168.0.32]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 802B9C177; Fri, 17 Feb 2006 22:53:45 +0100 (CET) Subject: Re: [Caml-list] Monomorphism restriction in classes From: Gerd Stolpmann To: Christian Stork Cc: caml-list@inria.fr In-Reply-To: <20060217210920.GA27593@anthony.ics.uci.edu> References: <20060217210920.GA27593@anthony.ics.uci.edu> Content-Type: text/plain Date: Fri, 17 Feb 2006 22:53:44 +0100 Message-Id: <1140213224.10403.33.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at concorde with ID 43F645F1.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43F645F0.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gerd:01 stolpmann:01 work-around:01 syntax:01 gerd:01 ocamlc:01 stolpmann:01 viktoriastr:01 64293:01 darmstadt:01 6151:01 6151:01 expression:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Am Freitag, den 17.02.2006, 13:09 -0800 schrieb Christian Stork: > So, what's the best work-around for this problem? > > class c (len : 'a list -> int) = > object > method str_len (l: string list) = len l > method int_len (l: int list) = len l > end > type len_t = { len : 'a . 'a list -> int} class c (len :len_t) = object method str_len (l:string list) = len.len l method int_len (l: int list) = len.len l end I don't know why the 'a.t syntax is only allowed for records and methods, and why one cannot say class c (len : 'a . 'a list -> int) = ... Gerd > $ ocamlc monoRestForClasses.ml > File "monoRestForClasses.ml", line 7, characters 40-41: > This expression has type int list but is here used with type string list > > Thanks, > Chris > -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------