From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8RCvaQS015936 for ; Tue, 27 Sep 2011 14:57:41 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQCAIXHgU7RVde2kGdsb2JhbABBmQKObwgUAQEBAQkJDQcUBCKBUwEBAQMBEgITEQgBGxIEBwEDAQsGBQsaISMRAQUBChIGJRCHVgIEm08Ki0yCXIUlO4huAgQGgxKDE2AEk1KFIoEqhj49g28 X-IronPort-AV: E=Sophos;i="4.68,449,1312149600"; d="scan'208";a="110752062" Received: from mail-ey0-f182.google.com ([209.85.215.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Sep 2011 14:57:40 +0200 Received: by eyg7 with SMTP id 7so7121012eyg.27 for ; Tue, 27 Sep 2011 05:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; bh=5wTlSaVqFkqNPc2qULfPr7KMg5ZyzjQac0t6vZSU/UI=; b=sc1IU6gVbi6TGXrGBwXDoQdomDN7m6BUV6S1gtYPfGWGOokFuteBkFChg1Bxf+H3nu wcPrK6ZNNMpHQoabKzc4+Zv0fi5nIvx1gaCcwE6IgNiEiViBJC+HXbuRH7UENHPHqg1y rklWYYjj0g0Rnm2CUMS7W3FNxddKN27svBoh0= Received: by 10.216.131.67 with SMTP id l45mr4685871wei.26.1317128260064; Tue, 27 Sep 2011 05:57:40 -0700 (PDT) Received: from [192.168.0.10] (lau06-5-88-176-33-221.fbx.proxad.net. [88.176.33.221]) by mx.google.com with ESMTPS id p13sm35713846wbh.13.2011.09.27.05.57.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Sep 2011 05:57:38 -0700 (PDT) Cc: OCaML Mailing List Message-Id: From: Christophe Papazian To: Walter Cazzola In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v936) Date: Tue, 27 Sep 2011 14:57:36 +0200 References: X-Mailer: Apple Mail (2.936) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8RCvaQS015936 Subject: Re: [Caml-list] still silly issues on polymorphic types Please remember how types can be subtypes of other types : consider val f : int -> int val g : int -> 'a val h : 'a -> int val i : 'a -> 'b then the most general type is the type of g and most specific type is type of h. In fact we have a diamond relation between types : h int) you can give h (if h can eat anything, it can eat int), but not g (i don't now how to handle 'a if I only need a int). So int is a subtype of 'a, but int -> int is not a subtype of 'a -> 'b, and 'a -> 'a is a valid subtype of int-> int. Le 27 sept. 11 à 13:46, Walter Cazzola a écrit : > Dear all, > I'm still playing around with functors, modules and polymorphism but > I've some problems with this last concept. > > In the attached files I have tried to implement a sort of function > with > a variable number of arguments (based on continuation) and to > generalize > the approach I've used a functor (OpVarADT) where I defined the > operation of type 'a -> 'b -> 'c but seems that it is not general > enough > to contain int->int->int or 'a -> 'a list -> 'a list > > This is the functor instantiation with the errors I get: > > # module M0 = Continuation(StringConcat) ;; > Error: Signature mismatch: > Modules do not match: > sig val op : 'a -> 'a list -> 'a list val init : 'a list end > is not included in > OpVarADT.OpVarADT > Values do not match: > val op : 'a -> 'a list -> 'a list > is not included in > val op : 'a -> 'b -> 'c > # module M1 = Continuation(Sum) ;; > Error: Signature mismatch: > Modules do not match: > sig val op : int -> int -> int val init : int end > is not included in > OpVarADT.OpVarADT > Values do not match: > val op : int -> int -> int > is not included in > val op : 'a -> 'b -> 'c > > I'm sure I'm doing something wrong but I can't see what, any help is > welcome > > TIA > > Walter > > -- > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >