From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA05949; Thu, 3 Apr 2003 17:05:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA05280 for ; Thu, 3 Apr 2003 17:05:45 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h33F5i503672 for ; Thu, 3 Apr 2003 17:05:45 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id 44CAD5DFE; Thu, 3 Apr 2003 18:05:44 +0300 (EEST) Date: Thu, 3 Apr 2003 18:05:37 +0300 Subject: Re: [Caml-list] mystified by typing of optional arguments Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: caml-list@inria.fr To: Francois Rouaix From: Ville-Pertti Keinonen In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Spam: no; 0.00; caml-list:01 typable:01 inferred:01 int:01 match:02 typing:03 similarly:03 arguments:03 let:04 type:07 function:09 opt:09 element:11 doesn't:12 but:16 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > The following example mystifies me > > let f ?opt x = > match opt with > | None -> x > | Some dx -> x + dx > > let g x = x + 1 > > > let h1 = function > | 0 -> [g] > | _ -> [f; g] > > > let h2 = function > | _ -> [f; g] > > > h1 is typable but not h2. > Why is that ? The type of the list is inferred from the first element of the first instance. Similarly: let x = [ g; f ] (* works *) let x = [ f; g ] (* doesn't work *) let x = [ (f : int -> int); g ] (* works *) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners