<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/10/0bc68c82ed4a6bba68f2636134143811"
  from="Jun Furuse &lt;jun.furuse@g...&gt;"
  author="Jun Furuse"
  date="2009-10-11T14:57:19"
  subject="Re: [Caml-list] Re: Improving OCaml&apos;s choice of type to display"
  prev="2009/10/c17c0e6481804fa9249bde60a00584c2"
  next="2009/10/8349209de209281dbf73cb3888588769"
  prev-in-thread="2009/10/87470a289690e18edbff126b5a7a8ac3"
  next-in-thread="2009/10/8349209de209281dbf73cb3888588769"
  prev-thread="2009/10/cc30b4a069b2db9ebf8f94287b328051"
  next-thread="2009/10/1b087dcc1f0f6132c02c68dbbb67bc95"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/16051196b9d9c0d5bf42b865d44384e1"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-10-09T01:40:28"
  subject="Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/87470a289690e18edbff126b5a7a8ac3"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-10-09T01:53:44"
  subject="Re: Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/0bc68c82ed4a6bba68f2636134143811"
  from="Jun Furuse &lt;jun.furuse@g...&gt;"
  author="Jun Furuse"
  date="2009-10-11T14:57:19"
  subject="Re: [Caml-list] Re: Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/8349209de209281dbf73cb3888588769"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-10-11T15:12:50"
  subject="Re: [Caml-list] Re: Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/a404572b7e870ab6714732d61e9bddd8"
  from="Jun Furuse &lt;jun.furuse@g...&gt;"
  author="Jun Furuse"
  date="2009-10-11T15:24:44"
  subject="Re: [Caml-list] Re: Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/178203bcf6f42213ff6d6e53b37b8707"
  from="Gilles Pirio &lt;gilles.ocaml@g...&gt;"
  author="Gilles Pirio"
  date="2009-10-11T19:57:29"
  subject="Re: [Caml-list] Re: Improving OCaml&apos;s choice of type to display">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/10/bbdefe2c53d985fa64407ffd30ff459f"
  from="Andrej Bauer &lt;andrej.bauer@a...&gt;"
  author="Andrej Bauer"
  date="2009-10-09T07:33:02"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/b3f619ad26ab41cd18d0a4116614e3e7"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-10-09T09:58:06"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/44e5fad445afd1b1dba8516fa33c6a94"
  from="Alp Mestan &lt;alp@m...&gt;"
  author="Alp Mestan"
  date="2009-10-09T10:54:35"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/a0a18c8e566ee5672d4e68e674953947"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-10-09T11:15:03"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
</msg>
</msg>
</msg>
<msg 
  url="2009/10/4f1ff557b4a8b3d66e406db6212e2860"
  from="Stephen Weeks &lt;sweeks@s...&gt;"
  author="Stephen Weeks"
  date="2009-10-09T18:14:12"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
</msg>
</msg>
</msg>
</thread>

<contents>
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 = Hashtbl.create 10;;
val tbl : ('_a, '_b) t = &lt;abstr&gt;      (* not Hashtbl.t, since Hashtbl is open *)

# type t = int;;
type t = int
# type long_name = int;;
type long_name = int
# (1 : t);;
- : t = 1                     (* t is the shorter than its original type int *)
# (1 : long_name);;
- : int = 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. Enjoy!

Jun

On Fri, Oct 9, 2009 at 10:53 AM, Yaron Minsky &lt;yminsky@gmail.com&gt; wrote:
&gt; And you can compete to come up with the most innocuous code that comes up
&gt; with the longest type.  Here's my current favorite:
&gt;
&gt; # open Option.Monad_infix;;
&gt; # Map.find m 3 &gt;&gt;| fun x -&gt; x + 1;;
&gt; - : int Core.Std.Option.Monad_infix.monad = Some 4
&gt;
&gt; Which of course could be rendered as:
&gt;
&gt; # open Option.Monad_infix;;
&gt; # Map.find m 3 &gt;&gt;| fun x -&gt; x + 1;;
&gt; - : int option = Some 4
&gt;
&gt; y
&gt;
&gt; On Thu, Oct 8, 2009 at 9:40 PM, Yaron Minsky &lt;yminsky@gmail.com&gt; wrote:
&gt;&gt;
&gt;&gt; Anyone who plays around with the Core library that Jane Street just
&gt;&gt; released can see showcased a rather ugly detail of how Core's design
&gt;&gt; interacts with how OCaml displays types.  Witness:
&gt;&gt;
&gt;&gt; # Int.of_string;;
&gt;&gt; - : string -&gt; Core.Std.Int.stringable = &lt;fun&gt;
&gt;&gt; # Float.of_string;;
&gt;&gt; - : string -&gt; Core_extended.Std.Float.stringable = &lt;fun&gt;
&gt;&gt;
&gt;&gt; I'd be much happier if this was rendered in the following equally correct
&gt;&gt; and more readable form:
&gt;&gt;
&gt;&gt; # Int.of_string;;
&gt;&gt; - : string -&gt; Int.t = &lt;fun&gt;
&gt;&gt; # Float.of_string;;
&gt;&gt; - : string -&gt; Float.t = &lt;fun&gt;
&gt;&gt;
&gt;&gt; Or even:
&gt;&gt;
&gt;&gt; # Int.of_string;;
&gt;&gt; - : string -&gt; int = &lt;fun&gt;
&gt;&gt; # Float.of_string;;
&gt;&gt; - : string -&gt; float = &lt;fun&gt;
&gt;&gt;
&gt;&gt; And this isn't just an issue in the top-level. The compiler also displays
&gt;&gt; types in the same difficult to read form.  I'm wondering if anyone has some
&gt;&gt; thoughts as to what we can do to make the compiler make better choices
&gt;&gt; here.  There are two issues to overcome:
&gt;&gt;
&gt;&gt; Dropping the module name.  I'd love to give the compiler the hint that
&gt;&gt; Core.Std. could be dropped from the prefix in a context where that module is
&gt;&gt; open.  This is what's done with the pervasives module already, I believe, so
&gt;&gt; it seems like it should be doable here.
&gt;&gt; Choosing shorter names.  This one seems harder, but there are various
&gt;&gt; different possibilities for what type name to print out, and a reasonable
&gt;&gt; heuristic to use might be to pick the shortest one.  Part of the reason
&gt;&gt; these issues come up is our use of standardized interface components (that's
&gt;&gt; where the "stringable" type name comes from).  I suspect this one will be
&gt;&gt; hard to fix, sadly.
&gt;&gt;
&gt;&gt; Anyway, we'd be happy with any suggestions on how to improve matters.
&gt;&gt;
&gt;&gt; y
&gt;
&gt;
&gt; _______________________________________________
&gt; Caml-list mailing list. Subscription management:
&gt; http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
&gt; Archives: http://caml.inria.fr
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs
&gt;
&gt;

</contents>

</message>

