From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 21D09BC48 for ; Thu, 31 Mar 2005 14:55:10 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2VCt9Do016051 for ; Thu, 31 Mar 2005 14:55:09 +0200 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 OAA00556 for ; Thu, 31 Mar 2005 14:55:09 +0200 (MET DST) Received: from haydn.is.nottingham.ac.uk (haydn.is.nottingham.ac.uk [128.243.40.92]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2VCt8RZ016043 for ; Thu, 31 Mar 2005 14:55:09 +0200 Received: from marian.cs.nott.ac.uk ([128.243.20.6] helo=Cs.Nott.AC.UK) by haydn.is.nottingham.ac.uk with smtp (Exim 3.36 #2) id 1DGzBy-0004jL-00; Thu, 31 Mar 2005 13:54:34 +0100 Received: from kiwi.cs.nott.ac.uk by marian.Cs.Nott.AC.UK id aa09141; 31 Mar 2005 13:48 BST Subject: Re: [Caml-list] When is a function polymorphic? From: Fermin Reig To: yminsky@cs.cornell.edu Cc: caml-list@inria.fr In-Reply-To: <891bd33905033104045705be7a@mail.gmail.com> References: <891bd339050330165142478f37@mail.gmail.com> <20050331.114253.48852731.garrigue@math.nagoya-u.ac.jp> <891bd33905033020045cad3ce2@mail.gmail.com> <20050331.173223.128566586.garrigue@math.nagoya-u.ac.jp> <891bd33905033104045705be7a@mail.gmail.com> Content-Type: text/plain Message-Id: <1112273293.17931.66.camel@kiwi> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 31 Mar 2005 13:48:14 +0100 Content-Transfer-Encoding: 7bit X-MailScanner-Information: Please contact staff-it-helpline@nottingham.ac.uk for more information X-MailScanner: Found to be clean X-MailScanner-From: fermin.reig@cs.nott.ac.uk X-Miltered: at nez-perce with ID 424BF32D.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 424BF32D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 fermin:01 reig:01 fermin:01 reig:01 nott:01 yaron:01 minsky:01 constructors:01 variants:01 'x':01 verbose:01 haskell:01 sml:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Thu, 2005-03-31 at 13:04, Yaron Minsky wrote: > On Thu, 31 Mar 2005 17:32:23 +0900 (JST), Jacques Garrigue > > Is it so difficult to make the extra constructors explicit? > > I'd say there are two issues. The first is that it really can be a > pain for large variant types, particularly when the contents of those > types are changing during development, and you don't want the function > in question to depend on anything other than the particular variants > being modified. > [...] In my code, I try to avoid catchall '_' and 'x' patterns when possible. I end up with long 'or' patterns, such as | (A _ | B _ | C _ | ...) -> ... This style, while more verbose, has one advantage: if I later add a new constructor to my type, the exhaustiveness analysis warns me of all places where I should check. (In fact, this is most useful during development, since that's when type definitions change.) Regarding the typing of # function Some x -> Some () | None -> None;; # function Some x -> Some () | x -> x;; both Haskell and SML do the same as Ocaml, but, unlike Ocaml, neither gives a polymorphic type when using an 'as x' pattern. Fermin This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.