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 p8RDwKZQ019267 for ; Tue, 27 Sep 2011 15:58:20 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjkBAMvVgU6flYLKmWdsb2JhbABBDqduFAEBAQEBCAsLBxQmgVMBAQQBJ1IFCwsYLgJVBogLuHSHCwSTUoUQi205 X-IronPort-AV: E=Sophos;i="4.68,449,1312149600"; d="ml'?mli'?scan'208";a="110765201" Received: from smtp.dico.unimi.it ([159.149.130.202]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Sep 2011 15:58:17 +0200 Received: from surtur.docenti.dico.unimi.it (surtur.docenti.dico.unimi.it [159.149.152.56]) (authenticated bits=0) by smtp.dico.unimi.it (8.14.4/8.14.4) with ESMTP id p8RDwAaI029612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Sep 2011 15:58:10 +0200 Date: Tue, 27 Sep 2011 15:58:10 +0200 (CEST) From: Walter Cazzola To: Jacques Garrigue cc: OCaML Mailing List In-Reply-To: <6A020199-D53D-443E-9683-D225D495AEB5@math.nagoya-u.ac.jp> Message-ID: References: <6A020199-D53D-443E-9683-D225D495AEB5@math.nagoya-u.ac.jp> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-166333812-1317131890=:8918" 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 15:58:10 +0200 (CEST) X-DSI-MailScanner-Information: Please contact the staff for more information X-DSI-MailScanner-ID: p8RDwAaI029612 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 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-166333812-1317131890=:8918 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Tue, 27 Sep 2011, Jacques Garrigue wrote: > On 2011/09/27, at 20:46, Walter Cazzola wrote: > >> 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 > It seems that your continuation functor has not the right specification. > Namely, there is no way you can provide a meaningful function of > type 'a -> 'b -> 'c (i.e. a -> b -> c for all possible a, b, and c) > other than raising an exception or going into an infinite loop. > I think that you meant something else, like > type a and b and c > val op : a -> b -> c > which would let you give a specific function for op. uhm, I've tried to follow your advice but the problem persists (attached the new version) when I try to apply the functor I get the following error: # module M1 = Continuation(Sum) ;; Error: Signature mismatch: Modules do not match: sig type a = int and b = int and c = int 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 But probably I misinterpreted your advice. Walter -- --8323328-166333812-1317131890=:8918 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=continuation.ml Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=continuation.ml bW9kdWxlIENvbnRpbnVhdGlvbiAoT1AgOiBPcFZhckFEVC5PcFZhckFEVCkg PSANCiAgc3RydWN0DQogICAgbGV0IGFyZyB4ID0gZnVuIHkgY29udGludWF0 aW9uIC0+IGNvbnRpbnVhdGlvbiAoT1Aub3AgeCB5KSA7Ow0KICAgIGxldCBz dG9wIHggPSB4OzsNCiAgICBsZXQgZiBnID0gZyBPUC5pbml0OzsNCiAgZW5k DQo= --8323328-166333812-1317131890=:8918 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=OpVarADT.mli Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=OpVarADT.mli bW9kdWxlIHR5cGUgT3BWYXJBRFQgPSANCiBzaWcNCiAgIHR5cGUgYSBhbmQg YiBhbmQgYw0KICAgdmFsIG9wOiBhIC0+IGIgLT4gYw0KICAgdmFsIGluaXQg OiAnYw0KIGVuZA0K --8323328-166333812-1317131890=:8918 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=sum.ml Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=sum.ml bW9kdWxlIFN1bSA9IHN0cnVjdA0KICB0eXBlIGE9aW50IGFuZCBiPWludCBh bmQgYz1pbnQNCiAgbGV0IG9wID0gZnVuIHggeSAtPiB4K3kgOzsNCiAgbGV0 IGluaXQgPSAwIDs7DQplbmQNCg== --8323328-166333812-1317131890=:8918--