From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8RIhs83029151 for ; Tue, 27 Sep 2011 20:43:54 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgEBABsZgk6flYLKmWdsb2JhbABBp30UAQEBAQEICwsHFCaBUwEBBAEnEQI/BQsLRlcGiAsCuiWHCwSTUoUQEowU X-IronPort-AV: E=Sophos;i="4.68,450,1312149600"; d="scan'208";a="121774738" Received: from smtp.dico.unimi.it ([159.149.130.202]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Sep 2011 20:43:49 +0200 Received: from [192.168.1.100] (dynamic-adsl-94-36-46-100.clienti.tiscali.it [94.36.46.100]) (authenticated bits=0) by smtp.dico.unimi.it (8.14.4/8.14.4) with ESMTP id p8RIhjgj017850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Sep 2011 20:43:46 +0200 Date: Tue, 27 Sep 2011 20:43:40 +0200 (CEST) From: Walter Cazzola To: Christophe Papazian cc: OCaML Mailing List In-Reply-To: <53C8B18E-A3AD-4DB1-A477-EE7FA7846845@gmail.com> Message-ID: References: <53C8B18E-A3AD-4DB1-A477-EE7FA7846845@gmail.com> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (smtp.dico.unimi.it [159.149.130.202]); Tue, 27 Sep 2011 20:43:46 +0200 (CEST) X-DSI-MailScanner-Information: Please contact the staff for more information X-DSI-MailScanner-ID: p8RIhjgj017850 X-DSI-MailScanner: Found to be clean X-DSI-MailScanner-From: cazzola@dico.unimi.it Subject: Re: [Caml-list] still silly issues on polymorphic types On Tue, 27 Sep 2011, Christophe Papazian wrote: >> uhm, I have a couple of questions I don't understand on your >> explanation: >> - why the most general type is int->'a and not 'a -> 'b? > Because if I need a function of type int -> 'a I can give a function of type > 'a -> 'b. > But if I need a function of type 'a -> 'b I can not use a function of type > int -> 'a. > So int -> 'a is more general and 'a -> 'b is more specific. > General rule : if a < b then (a->c) > (b->c) probably this is a question whose answer will be RTFM but I'll try to get your mercy (;-)): what define that a is lesser than b? is there a table of the precendece among types? >> - does this mean that I can't have a general type that could be matched >> by 'a -> 'a list -> 'a list and int -> int -> int ? > if you want to get a supertype of a -> b and c -> d you need to > find a subtype of a and c AND find a supertype of b and d. > So for example for ('a -> ( 'a list -> 'a list)) and (int -> (int -> int)) > you need > - a subtype of 'a and int : it's int. you have one. > - a supertype of ('a list -> 'a list) and (int -> int) (reapply the same > procedure) > -a subtype of 'a list and int : there is no such thing in ocaml, so > there is no supertype. ok I see > So to answer your question, you can't. But as Jacques Garrigue said, you > don't need either, and you can use abstract type and "with type" > construction. uhm, as I replied to Jacques I tried but the error persists probably I don't know enough OCaML to do that. thanks a lot Walter --