From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 78780BCAE for ; Mon, 11 Jul 2005 08:11:36 +0200 (CEST) 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 j6B6BZ6o010524 for ; Mon, 11 Jul 2005 08:11:35 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA30031 for ; Mon, 11 Jul 2005 08:11:35 +0200 (MET DST) Received: from smtpauth09.mail.atl.earthlink.net (smtpauth09.mail.atl.earthlink.net [209.86.89.69]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6B6BY6r027391 for ; Mon, 11 Jul 2005 08:11:35 +0200 Received: from [63.231.101.77] (helo=[192.168.1.101]) by smtpauth09.mail.atl.earthlink.net with asmtp (TLSv1:RC4-MD5:128) (Exim 4.34) id 1DrrVu-0005eV-5D for caml-list@inria.fr; Mon, 11 Jul 2005 02:11:34 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=test1; d=earthlink.net; h=Message-ID:Date:From:Reply-To:User-Agent:X-Accept-Language:MIME-Version:To:Subject:References:In-Reply-To:X-Enigmail-Version:X-Enigmail-Supports:Content-Type:Content-Transfer-Encoding; b=XxrQS9HNsvavESwpzU0iJIWp7712OGlM8/DRRg1ReBuAXR5gciMQN7hTa5Z3mh4Z; Message-ID: <42D2106D.5080508@earthlink.net> Date: Mon, 11 Jul 2005 00:23:41 -0600 From: "Matthew O'Connor" Reply-To: mboconnor@acm.org User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Object typing References: <42D063EC.3040900@earthlink.net> <20050711.000642.115315345.debian00@tiscali.be> In-Reply-To: <20050711.000642.115315345.debian00@tiscali.be> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-ELNK-Trace: c5e7d5cff6dcd352d780f4a490ca69563f9fea00a6dd62bcb2acc4ac1ff52a97f5f5aac6179a180a350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 63.231.101.77 X-Miltered: at concorde with ID 42D20D97.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42D20D96.006 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 christophe:01 troestler:01 variants:01 bool:01 bool:01 forall:01 parametrize:01 2005,:98 wrote:01 wrote:01 unbound:01 polymorphic:01 typing:01 hierarchy:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Christophe TROESTLER wrote: > On Sat, 09 Jul 2005, "Matthew O'Connor" wrote: > >>Here is a version of what I would like to be able to do, but can't or >>don't know how. I would like to use polymorphic variants to enable >>easier extensibility of the hierarchy. > > > To understand what does not work, try > > class entity = > object > method is_a v = (v = `Entity) > end > > You get an error message of which the important part is "The method > is_a has type ([> `Entity ] as 'a) -> bool where 'a is unbound". It > says that the method [is_a] is of type 'a -> bool with a constraint on > 'a. Since you do not want a method of type (forall 'a) 'a -> bool > (written "'a. ([> ] as 'a) -> bool" in your error message), you > parametrize the class by that type 'a (the rest is in interactive > mode): Ahh, thank you for the explanation. > # class ['a] entity = > object > method is_a (v:'a) = (v = `Entity) > end;; > class ['a] entity : > object constraint 'a = [> `Entity ] method is_a : 'a -> bool end Yes, this is exactly what I was looking for. Again, thanks to all who answered. Matt