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 RAA05205; Thu, 3 Apr 2003 17:13:25 +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 RAA04743 for ; Thu, 3 Apr 2003 17:13:24 +0200 (MET DST) Received: from cgpsrv1.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h33FDN504356 for ; Thu, 3 Apr 2003 17:13:23 +0200 (MET DST) Received: from [130.113.68.27] (account carette@univmail.cis.mcmaster.ca HELO pccarettej) by cgpsrv1.cis.mcmaster.ca (CommuniGate Pro SMTP 3.5.9) with ESMTP id 36638795; Thu, 03 Apr 2003 10:13:11 -0500 Reply-To: From: "Jacques Carette" To: "'Francois Rouaix'" , Subject: RE: [Caml-list] mystified by typing of optional arguments Date: Thu, 3 Apr 2003 10:13:17 -0500 Organization: McMaster University Message-ID: <001401c2f9f3$8e371960$1b447182@cas.mcmaster.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal In-Reply-To: X-Spam: no; 0.00; jacques:01 caml-list:01 3.06:01 unification:01 underlies:01 typable:01 reproducing:01 bug:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This can be simplified further: let f ?opt x = match opt with | None -> x | Some dx -> x + dx let g x = x + 1 Then (in ocaml 3.06) # [f;g];; Characters 3-4: [f;g];; ^ This expression has type int -> int but is here used with type ?opt:int -> int -> int # [g;f];; - : (int -> int) list = [; ] In other words it looks like unification of optional types is not commutative ! This is indeed surprising. I can understand that this could simplify implementation, but is there a theoretical reason that underlies this ? Jacques -----Original Message----- From: owner-caml-list@pauillac.inria.fr [mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of Francois Rouaix Sent: April 3, 2003 9:51 AM To: caml-list@inria.fr Subject: [Caml-list] mystified by typing of optional arguments Hi all, 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 ? --f PS: the example code is not meant to be useful in any way other than reproducing the behavior of type checking. ------------------- 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 ------------------- 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