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=1.4 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL 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 F04C0BC37 for ; Sun, 11 Oct 2009 16:57:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AocDAKOO0UpKfVwbimdsb2JhbACDAIxUgXGJCD8BAQEKCQwHEQWqKIE6hQuIZQEDAwWEKASCPA X-IronPort-AV: E=Sophos;i="4.44,542,1249250400"; d="scan'208";a="48381640" Received: from qw-out-2122.google.com ([74.125.92.27]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Oct 2009 16:57:18 +0200 Received: by qw-out-2122.google.com with SMTP id 5so1024115qwd.15 for ; Sun, 11 Oct 2009 07:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=NpecHYYv7tAygkHRMMXcOlQh3xAfQCK1wlIDTxkLsNw=; b=wazB4F8Grm3x+b0WlXHSg8EropkMCpab7DAbJNEOUsiNJ3Vn25v/XtN0+7+ts/WpKV OojEeajqYb4nCvfAl4HoQp8Wr+KtrVDPr5JXLCZ8KAf4xbuvEHzz0dgg5wVWbzBsny2v GGmWZxCA58KMJ+1WunmPgWwI/A52WQ1Eo/pQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=EGnqwtstPkZShIv1Sapzd432Ur/Z5pgo7o8JReK+aQneRhN4fQOfI32Q/CiASs2Ofp kjgO9P8MDN51MNBOjLwA2roZn5XBcH+LbMIW9WtzYYqyjCM4OuCa0mhkNeqOInOGmOPx tcs8F01h94qtNxJ+0irg1yWQC8n/a+IwBBpak= MIME-Version: 1.0 Received: by 10.229.1.167 with SMTP id 39mr2112219qcf.99.1255273036489; Sun, 11 Oct 2009 07:57:16 -0700 (PDT) In-Reply-To: <891bd3390910081853m5409c871y35495c6f16e180aa@mail.gmail.com> References: <891bd3390910081840p37e8c786g60b2c15d2c06ae60@mail.gmail.com> <891bd3390910081853m5409c871y35495c6f16e180aa@mail.gmail.com> Date: Sun, 11 Oct 2009 23:57:16 +0900 Message-ID: <5160b4200910110757y47ffad15v70434418cba61f26@mail.gmail.com> Subject: Re: [Caml-list] Re: Improving OCaml's choice of type to display From: Jun Furuse To: yminsky@gmail.com Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml's:01 furuse:01 furuse:01 hashtbl:01 hashtbl:01 val:01 abstr:01 yaron:01 minsky:01 yminsky:01 infix:01 infix:01 yaron:01 minsky:01 yminsky:01 I have quickly wrote a small patch against 3.11.1 for this feature, to see what it would be like. http://sites.google.com/a/furuse.info/jun/hacks/other-small-ocaml-patches With this patch, path names are printed without opened modules in the context. It also tries heuristic data type name simplification: if a variant/record data type is an alias of another data type whose name is shorter than the original, the printer uses the latter. For example: # open Hashtbl;; # let tbl =3D Hashtbl.create 10;; val tbl : ('_a, '_b) t =3D (* not Hashtbl.t, since Hashtbl is = open *) # type t =3D int;; type t =3D int # type long_name =3D int;; type long_name =3D int # (1 : t);; - : t =3D 1 (* t is the shorter than its original type = int *) # (1 : long_name);; - : int =3D 1 (* int is shorter name for long_name. t is even shorter but not aliased unfortunatelly. *) I warn you that the patch is very quickly written and not tested well. Enjo= y! Jun On Fri, Oct 9, 2009 at 10:53 AM, Yaron Minsky wrote: > And you can compete to come up with the most innocuous code that comes up > with the longest type.=A0 Here's my current favorite: > > # open Option.Monad_infix;; > # Map.find m 3 >>| fun x -> x + 1;; > - : int Core.Std.Option.Monad_infix.monad =3D Some 4 > > Which of course could be rendered as: > > # open Option.Monad_infix;; > # Map.find m 3 >>| fun x -> x + 1;; > - : int option =3D Some 4 > > y > > On Thu, Oct 8, 2009 at 9:40 PM, Yaron Minsky wrote: >> >> Anyone who plays around with the Core library that Jane Street just >> released can see showcased a rather ugly detail of how Core's design >> interacts with how OCaml displays types.=A0 Witness: >> >> # Int.of_string;; >> - : string -> Core.Std.Int.stringable =3D >> # Float.of_string;; >> - : string -> Core_extended.Std.Float.stringable =3D >> >> I'd be much happier if this was rendered in the following equally correc= t >> and more readable form: >> >> # Int.of_string;; >> - : string -> Int.t =3D >> # Float.of_string;; >> - : string -> Float.t =3D >> >> Or even: >> >> # Int.of_string;; >> - : string -> int =3D >> # Float.of_string;; >> - : string -> float =3D >> >> And this isn't just an issue in the top-level. The compiler also display= s >> types in the same difficult to read form.=A0 I'm wondering if anyone has= some >> thoughts as to what we can do to make the compiler make better choices >> here.=A0 There are two issues to overcome: >> >> Dropping the module name.=A0 I'd love to give the compiler the hint that >> Core.Std. could be dropped from the prefix in a context where that modul= e is >> open.=A0 This is what's done with the pervasives module already, I belie= ve, so >> it seems like it should be doable here. >> Choosing shorter names.=A0 This one seems harder, but there are various >> different possibilities for what type name to print out, and a reasonabl= e >> heuristic to use might be to pick the shortest one.=A0 Part of the reaso= n >> these issues come up is our use of standardized interface components (th= at's >> where the "stringable" type name comes from).=A0 I suspect this one will= be >> hard to fix, sadly. >> >> Anyway, we'd be happy with any suggestions on how to improve matters. >> >> y > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >