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 FAA09487; Wed, 4 Jun 2003 05:23:46 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA09248 for ; Wed, 4 Jun 2003 05:23:45 +0200 (MET DST) Received: from ux9.sp.cs.cmu.edu (UX9.SP.CS.CMU.EDU [128.2.220.166]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h543NiT24169 for ; Wed, 4 Jun 2003 05:23:44 +0200 (MET DST) Received: from 12-203-128-226.client.attbi.com ([12.203.128.226]) by ux9.sp.cs.cmu.edu id aa19125; 3 Jun 2003 23:23 EDT Received: from ecc by stratocaster.home with local (Exim 3.36 #1 (Debian)) id 19NOs0-0001Z4-00 for ; Tue, 03 Jun 2003 23:23:24 -0400 Date: Tue, 3 Jun 2003 23:23:24 -0400 To: caml-list@inria.fr Subject: Re: [Caml-list] optional arguments and unification Message-ID: <20030604032324.GA5986@ecooper.com> Mail-Followup-To: caml-list@inria.fr References: <4.3.2.7.2.20030603195340.032a40e0@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4.3.2.7.2.20030603195340.032a40e0@localhost> User-Agent: Mutt/1.5.4i From: "Eric C. Cooper" X-Spam: no; 0.00; caml-list:01 unification:01 hecker:01 chris:01 0700,:01 int:01 wrote:03 arguments:03 let:04 cooper:06 eric:06 type:07 fun:08 opt:09 tue:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Jun 03, 2003 at 07:58:19PM -0700, Chris Hecker wrote: > let f ?opt x = x + 1 > let g x = x + 1 > let h = if true then f else g > > This expression has type int -> int but is here used with type > ?opt:'a -> int -> int > > So you have to do this: > > let h = if true then f ?opt:None else g You could also write: let h = if true then (fun x -> f x) else g or even let h = let f x = f x in if true then f else g -- Eric C. Cooper e c c @ c m u . e d u ------------------- 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