From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 3E7BDBBAF for ; Fri, 9 Oct 2009 17:28:08 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4BANfzzkpRZ90wkWdsb2JhbACbBAEBAQEJCwoHEwO/c4QqBA X-IronPort-AV: E=Sophos;i="4.44,533,1249250400"; d="scan'208";a="48303569" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail4-smtp-sop.national.inria.fr with ESMTP; 09 Oct 2009 17:27:29 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20091009152725.GPMY27507.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Fri, 9 Oct 2009 16:27:25 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20091009152725.LZUS21638.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com>; Fri, 9 Oct 2009 16:27:25 +0100 Received: from Tenor ([172.16.0.8]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id n99FRL4L001232 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 9 Oct 2009 16:27:22 +0100 From: "David Allsopp" To: "'Vincent Aravantinos'" , "'Damien Guichard'" Cc: References: <891bd3390910081840p37e8c786g60b2c15d2c06ae60@mail.gmail.com>, <7d8707de0910090033q4a14a108w62f13d7735994923@mail.gmail.com>, <891bd3390910090258l61aa7947p67a10c4adcc3312a@mail.gmail.com> <200910091618143281094@orange.fr> <906B3DB3-5804-4C62-9044-EF5F3968AB4B@gmail.com> In-Reply-To: <906B3DB3-5804-4C62-9044-EF5F3968AB4B@gmail.com> Subject: RE: [Caml-list] Improving OCaml's choice of type to display Date: Fri, 9 Oct 2009 16:27:19 +0100 Message-ID: <001b01ca48f4$fe9099f0$fbb1cdd0$@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcpI7xuL19HI/21iSBig73sklZCiUQAAnJ4Q Content-Language: en-gb Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.0 c=1 a=KJeY4yFSV4UA:10 a=3Zv74xsiPMVNAu9UftIA:9 a=9e1NUzd6J_uSg772_OQA:7 a=OuRk3ixZ8GKj4q3jvMTtyocE66sA:4 X-Spam: no; 0.00; ocaml's:01 damien:01 guichard:01 ocaml:01 val:01 ocaml:01 val:01 functors:01 foo:01 foo:01 caml-list:01 int:01 int:01 inferred:02 inferred:02 > Le 9 oct. 09 =E0 16:18, Damien Guichard a =E9crit : > > > Imagine my code is: >=A0 >=A0 type color =3D int >=A0 >=A0 let black : color =3D 0=A0 >=A0 > Then, following your proposition, evaluating=A0black=A0should give me an=A0int=A0rather than a=A0color=A0because=A0int=A0is shorter and = therefore nicer. Hmm, I'd say that having OCaml respond "val black : int =3D 0" is indeed = the more useful answer (but not because int is shorter)... there are quite = often times where you get complex looking types (for good reason) which are in fact aliases of much simpler types where it would (IMO) be much nicer = for OCaml to "call a spade a spade" and just tell you it's an int (Set.Make = and Map.Make being obvious cases[1]). Perhaps OCaml could make us both happy = by responding "val black : color =3D int =3D 0" (i.e. show the inferred and possibly aliased type and also the principal base type, if it's = different from the inferred type) The "unnecessary" complexity of the type names can also arise quite = easily if you're using with functors so need to present a particular type to satisfy a signature - at which point having Foo.Bar.Other.Module.t = (which is in fact an int) may create irritatingly long type messages but the = structure being that way is probably hugely useful when it gets applied to Magic.Make(Foo) elsewhere... David [1] Consider, somewhat obtusely, [let x : Map.Make(String).key =3D ""] = (which in real code is inferred rather more trivially from anything = manipulating sets and maps)