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 p8TF7x1t005461 for ; Thu, 29 Sep 2011 17:07:59 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQBAAOJhE6flYLKhWdsb2JhbABBqA4UAQEBCgsLGyWCARECgXEMoQmfX4cTBJNWhRGMKw X-IronPort-AV: E=Sophos;i="4.68,461,1312149600"; d="scan'208";a="111153311" Received: from smtp.dico.unimi.it ([159.149.130.202]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Sep 2011 17:07:54 +0200 Received: from ulik.disi.unige.it (ulik.disi.unige.it [130.251.61.165]) (authenticated bits=0) by smtp.dico.unimi.it (8.14.4/8.14.4) with ESMTP id p8TF7nc7015055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 29 Sep 2011 17:07:49 +0200 Date: Thu, 29 Sep 2011 17:07:43 +0200 (CEST) From: Walter Cazzola To: OCaML Mailing List Message-ID: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (smtp.dico.unimi.it [159.149.130.202]); Thu, 29 Sep 2011 17:07:49 +0200 (CEST) X-DSI-MailScanner-Information: Please contact the staff for more information X-DSI-MailScanner-ID: p8TF7nc7015055 X-DSI-MailScanner: Found to be clean X-DSI-MailScanner-From: cazzola@dico.unimi.it Subject: [Caml-list] still puzzled on generic types Dear all, waiting for some hints on my other issue for functors and generic I was playing with an enumerate function (with tail recursion): let rec enumerate ?(l':((int * 'a) list)=[]) ?(n=0) l = match l with h::l1 -> enumerate (l'@[(n,h)]) (n+1) l1 | [] -> l' this should just take a list and return a list of couple whose first entry is the position in the list of the element; to be clearer: enumerate ['a'; 'b'; 'c'] -> [(0,'a'); (1,'b'); (2,'c')]; but this doesn't work as by type mismatch: Error: This expression has type (int * 'a) list but an expression was expected of type 'a list Doesn't a matter if I've annotated the type (int * 'a) list to the optional argument l' when I try to call the function with the new value it says that the two things don't have the same type. I'm quite puzzled by this behavior, any explanation/help is welcome as usual. Walter --