<?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/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"
  prev="2009/10/0bc68c82ed4a6bba68f2636134143811"
  next="2009/10/a404572b7e870ab6714732d61e9bddd8"
  prev-in-thread="2009/10/0bc68c82ed4a6bba68f2636134143811"
  next-in-thread="2009/10/a404572b7e870ab6714732d61e9bddd8"
  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>
Cool!  That was quick.

Does this patch also implement stephen's fewest-number-of-dots  
heuristic?  I was thinking one nice approach would be fewest-number-of- 
dots with ties broken by length of final identifier.

Y

Yaron Minsky

On Oct 11, 2009, at 10:57 AM, Jun Furuse &lt;jun.furuse@gmail.com&gt; wrote:

&gt; I have quickly wrote a small patch against 3.11.1 for this feature, to
&gt; see what it would be like.
&gt;
&gt; http://sites.google.com/a/furuse.info/jun/hacks/other-small-ocaml-patches
&gt;
&gt; With this patch, path names are printed without opened modules in the
&gt; context. It also tries heuristic data type name simplification: if a
&gt; variant/record data type is an alias of another data type whose name
&gt; is shorter than the original, the printer uses the latter.
&gt;
&gt; For example:
&gt;
&gt; # open Hashtbl;;
&gt; # let tbl = Hashtbl.create 10;;
&gt; val tbl : ('_a, '_b) t = &lt;abstr&gt;      (* not Hashtbl.t, since  
&gt; Hashtbl is open *)
&gt;
&gt; # type t = int;;
&gt; type t = int
&gt; # type long_name = int;;
&gt; type long_name = int
&gt; # (1 : t);;
&gt; - : t = 1                     (* t is the shorter than its original  
&gt; type int *)
&gt; # (1 : long_name);;
&gt; - : int = 1                   (* int is shorter name for long_name. t
&gt; is even shorter but not aliased unfortunatelly. *)
&gt;
&gt; I warn you that the patch is very quickly written and not tested  
&gt; well. Enjoy!
&gt;
&gt; Jun
&gt;
&gt; On Fri, Oct 9, 2009 at 10:53 AM, Yaron Minsky &lt;yminsky@gmail.com&gt;  
&gt; wrote:
&gt;&gt; And you can compete to come up with the most innocuous code that  
&gt;&gt; comes up
&gt;&gt; with the longest type.  Here's my current favorite:
&gt;&gt;
&gt;&gt; # open Option.Monad_infix;;
&gt;&gt; # Map.find m 3 &gt;&gt;| fun x -&gt; x + 1;;
&gt;&gt; - : int Core.Std.Option.Monad_infix.monad = Some 4
&gt;&gt;
&gt;&gt; Which of course could be rendered as:
&gt;&gt;
&gt;&gt; # open Option.Monad_infix;;
&gt;&gt; # Map.find m 3 &gt;&gt;| fun x -&gt; x + 1;;
&gt;&gt; - : int option = Some 4
&gt;&gt;
&gt;&gt; y
&gt;&gt;
&gt;&gt; On Thu, Oct 8, 2009 at 9:40 PM, Yaron Minsky &lt;yminsky@gmail.com&gt;  
&gt;&gt; wrote:
&gt;&gt;&gt;
&gt;&gt;&gt; Anyone who plays around with the Core library that Jane Street just
&gt;&gt;&gt; released can see showcased a rather ugly detail of how Core's design
&gt;&gt;&gt; interacts with how OCaml displays types.  Witness:
&gt;&gt;&gt;
&gt;&gt;&gt; # Int.of_string;;
&gt;&gt;&gt; - : string -&gt; Core.Std.Int.stringable = &lt;fun&gt;
&gt;&gt;&gt; # Float.of_string;;
&gt;&gt;&gt; - : string -&gt; Core_extended.Std.Float.stringable = &lt;fun&gt;
&gt;&gt;&gt;
&gt;&gt;&gt; I'd be much happier if this was rendered in the following equally  
&gt;&gt;&gt; correct
&gt;&gt;&gt; and more readable form:
&gt;&gt;&gt;
&gt;&gt;&gt; # Int.of_string;;
&gt;&gt;&gt; - : string -&gt; Int.t = &lt;fun&gt;
&gt;&gt;&gt; # Float.of_string;;
&gt;&gt;&gt; - : string -&gt; Float.t = &lt;fun&gt;
&gt;&gt;&gt;
&gt;&gt;&gt; Or even:
&gt;&gt;&gt;
&gt;&gt;&gt; # Int.of_string;;
&gt;&gt;&gt; - : string -&gt; int = &lt;fun&gt;
&gt;&gt;&gt; # Float.of_string;;
&gt;&gt;&gt; - : string -&gt; float = &lt;fun&gt;
&gt;&gt;&gt;
&gt;&gt;&gt; And this isn't just an issue in the top-level. The compiler also  
&gt;&gt;&gt; displays
&gt;&gt;&gt; types in the same difficult to read form.  I'm wondering if anyone  
&gt;&gt;&gt; has some
&gt;&gt;&gt; thoughts as to what we can do to make the compiler make better  
&gt;&gt;&gt; choices
&gt;&gt;&gt; here.  There are two issues to overcome:
&gt;&gt;&gt;
&gt;&gt;&gt; Dropping the module name.  I'd love to give the compiler the hint  
&gt;&gt;&gt; that
&gt;&gt;&gt; Core.Std. could be dropped from the prefix in a context where that  
&gt;&gt;&gt; module is
&gt;&gt;&gt; open.  This is what's done with the pervasives module already, I  
&gt;&gt;&gt; believe, so
&gt;&gt;&gt; it seems like it should be doable here.
&gt;&gt;&gt; Choosing shorter names.  This one seems harder, but there are  
&gt;&gt;&gt; various
&gt;&gt;&gt; different possibilities for what type name to print out, and a  
&gt;&gt;&gt; reasonable
&gt;&gt;&gt; heuristic to use might be to pick the shortest one.  Part of the  
&gt;&gt;&gt; reason
&gt;&gt;&gt; these issues come up is our use of standardized interface  
&gt;&gt;&gt; components (that's
&gt;&gt;&gt; where the "stringable" type name comes from).  I suspect this one  
&gt;&gt;&gt; will be
&gt;&gt;&gt; hard to fix, sadly.
&gt;&gt;&gt;
&gt;&gt;&gt; Anyway, we'd be happy with any suggestions on how to improve  
&gt;&gt;&gt; matters.
&gt;&gt;&gt;
&gt;&gt;&gt; y
&gt;&gt;
&gt;&gt;
&gt;&gt; _______________________________________________
&gt;&gt; Caml-list mailing list. Subscription management:
&gt;&gt; http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
&gt;&gt; Archives: http://caml.inria.fr
&gt;&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt;&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs
&gt;&gt;
&gt;&gt;

</contents>

</message>

