caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Fwd: Re: [Caml-list] Re: Improving OCaml's choice of type to display]
@ 2009-10-12  8:58 Julien Signoles
  0 siblings, 0 replies; 2+ messages in thread
From: Julien Signoles @ 2009-10-12  8:58 UTC (permalink / raw)
  To: caml list

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Sorry, forgot the caml-list.

[-- Attachment #2: Re: [Caml-list] Re: Improving OCaml's choice of type to display.eml --]
[-- Type: message/rfc822, Size: 2104 bytes --]

From: Julien Signoles <Julien.Signoles@cea.fr>
To: Jun Furuse <jun.furuse@gmail.com>
Subject: Re: [Caml-list] Re: Improving OCaml's choice of type to display
Date: Mon, 12 Oct 2009 10:57:34 +0200
Message-ID: <4AD2EF7E.2080105@cea.fr>

Jun Furuse a écrit :
> I have not tested it well but it counts dots and should try to find
> the minimal one.
> 
> A problem I have found so far is that it prints something confusing, ex.
> 
> module M = struct type t end
> module N = struct type t end
> open M
> open N
> 
> let _ = ( 1 : M.t )
> 
>>> Error: This expression has type int but an expression was expected of type t    (which t ?!?!?)

 From the typing environment, it refers to N.t. Hence the type error 
message is not correct.

> If there are types M.t and N.t and the both of M and N are opened,
> these types are printed just "t". This can be avoided by testing the
> result name "t" against the current typing envrionment to see it
> really means the original type "M.t". This requires more coding but
> the weekend has ended in the far east already :-)   (It's 0:24 Monday
> now.)

One solution could be the following.

Let M.t the unique long type name to simplify and let P the longest 
prefix of M removed with the "do not print opened modules" rule.
After simplifying the long name M.t to (M - P).t (that is what your 
implementation does, if I well understood), add the shortest suffix S of 
M.t such that (M - P).S.t is visible in the current typing environment.

Don't know how hard is to implement such a solution in the caml compiler.

--
Julien


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Fwd: Re: [Caml-list] Re: Improving OCaml's choice of type to display]
@ 2009-10-12  8:58 Julien Signoles
  0 siblings, 0 replies; 2+ messages in thread
From: Julien Signoles @ 2009-10-12  8:58 UTC (permalink / raw)
  To: caml list

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Sorry, forgot the caml-list.

[-- Attachment #2: Re: [Caml-list] Re: Improving OCaml's choice of type to display.eml --]
[-- Type: message/rfc822, Size: 1882 bytes --]

From: Julien Signoles <Julien.Signoles@cea.fr>
To: Jun Furuse <jun.furuse@gmail.com>
Subject: Re: [Caml-list] Re: Improving OCaml's choice of type to display
Date: Mon, 12 Oct 2009 10:48:36 +0200
Message-ID: <4AD2ED64.8020408@cea.fr>

Jun Furuse a écrit :
> 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. 

Do not print included modules as well would be better. However, after a 
quick look in the source of the caml compiler, it seems to be really 
harder to implement that the "do not print opened" rule.

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.

> # 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 definitevely prefer to have long_name instead of int here: long_name 
is the name that the user choses in this context. From my point of view, 
the compiler should always use the name choosen by the user whenever 
possible.

--
Julien


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-12  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12  8:58 [Fwd: Re: [Caml-list] Re: Improving OCaml's choice of type to display] Julien Signoles
  -- strict thread matches above, loose matches on Subject: below --
2009-10-12  8:58 Julien Signoles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).