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=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 36560BBC1 for ; Wed, 12 Mar 2008 23:13:38 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQCAEry10fAXQInh2dsb2JhbACQcQEBAQgKKZZm X-IronPort-AV: E=Sophos;i="4.25,490,1199660400"; d="scan'208";a="23695252" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 12 Mar 2008 23:13:38 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2CMDbj5031555 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 12 Mar 2008 23:13:37 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQCAA7y10dQRFuwh2dsb2JhbACQcQEBAQgKKZZn X-IronPort-AV: E=Sophos;i="4.25,490,1199660400"; d="scan'208";a="9356312" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Mar 2008 23:13:37 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JZZCa-0004Uf-0V; Wed, 12 Mar 2008 22:13:36 +0000 Date: Wed, 12 Mar 2008 22:13:35 +0000 To: Olivier Andrieu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Yet another question about insufficient polymorphism Message-ID: <20080312221335.GA16935@annexia.org> References: <20080312193431.GA10622@annexia.org> <95513600803121319y508923a1vb36ac59c21e93f5b@mail.gmail.com> <20080312205911.GA14545@annexia.org> <95513600803121457l17e90817y54d419784462ae85@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <95513600803121457l17e90817y54d419784462ae85@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at concorde with ID 47D85591.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; polymorphism:01 0100,:01 andrieu:01 0100,:01 andrieu:01 -'a:01 covariance:01 val:01 val:01 coercions:01 -'a:01 omitting:01 textbox:98 textbox:98 wrote:01 [Hope you don't mind this but I've CC'd back to caml-list ...] On Wed, Mar 12, 2008 at 10:57:46PM +0100, Olivier Andrieu wrote: > On Wed, Mar 12, 2008 at 9:59 PM, Richard Jones wrote: > > On Wed, Mar 12, 2008 at 09:19:32PM +0100, Olivier Andrieu wrote: > > > aren't you missing a variance annotation ? like : > > > > > > type -'a component > > > > I don't know because no one has ever been able to explain covariance & > > contravariance to me in a comprehensible way ! > > there's this post where I tried to explain that to someone: > http://groups.google.com/group/fa.caml/msg/584ea2139b69f0ed > > > I added the '-' but it doesn't appear to have fixed the problem > > unfortunately. > > You'll need it anyway I think :) > What's the type of your functions that create components ? (textbox > and button ?) val button : int -> int -> string -> [ `Button | `Component ] component val textbox : int -> int -> int -> int -> flag list -> [ `Component | `Textbox ] component > > Someone mentioned that it might be because when I added the signature, > > the type became abstract (before, the implementation of the type was > > exposed). I can't make that work either though, but maybe because my > > type is slightly different than it was before ... > > You'll probably have to add some coercions , like: > > let as_co c = (c :> [`Component] component) > > and then > > form_add_components form [as_co text; as_co b1; as_co b2]; Right, this is very confusing. Adding the -'a annotation: type -'a component and: let as_co c = (c :> [`Component] component) in form_add_components form [as_co text; as_co b1; as_co b2]; works. However omitting the minus in "type -'a ..." breaks it, and changing the list to: ([text; b1; b2] :> [`Component] component list) doesn't work either. I guess I'll need to read about co-/contra-variance. Rich. -- Richard Jones Red Hat