[Caml-list] Improving OCaml's choice of type to display

2009-10-08 Thread Yaron Minsky
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. Witness: # Int.of_string;; - : string -> Core.Std.Int.stringable = # Float.of_string;; - : string -> Core_extended.Std

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Andrej Bauer
On Fri, Oct 9, 2009 at 3:40 AM, Yaron Minsky wrote: > Choosing shorter names. By which you probably mean "the fewest number of dots (module projections)". It might be a bit annoying if the code that prints doesn't know what modules are open. What do the INRIA priests say? Andrej ___

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Yaron Minsky
Well, if we're picking heuristics, the fewest number of characters wouldn't be crazy either. Given the choice between Int.t and Int.comparable (which are aliases for the same type), I'd prefer to see Int.t. y On Fri, Oct 9, 2009 at 3:33 AM, Andrej Bauer wrote: > On Fri, Oct 9, 2009 at 3:40 AM,

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Alp Mestan
Can't there be a trick by playing with, e.g, ocamlmktop, which could open Core and its main submodules by default, like it's done with Pervasives and, IIRC, Batteries ? On Fri, Oct 9, 2009 at 11:58 AM, Yaron Minsky wrote: > Well, if we're picking heuristics, the fewest number of characters would

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Yaron Minsky
On Fri, Oct 9, 2009 at 6:54 AM, Alp Mestan wrote: > Can't there be a trick by playing with, e.g, ocamlmktop, which could open > Core and its main submodules by default, like it's done with Pervasives and, > IIRC, Batteries ? > Maybe. Although to be honest my main concern is not with the top-lev

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Damien Guichard
en En réponse au message de : Yaron Minsky du : 2009-10-09 11:58:11 À : Andrej Bauer CC : caml-list@yquem.inria.fr Sujet : Re: [Caml-list] Improving OCaml's choice of type to display Well, if we're picking heuristics, the fewest number of characters wouldn't be crazy either. Given

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Vincent Aravantinos
Hi, can't you just say that you spotted a problem in the proposed solution instead of being so aggressive? Removing all the useless sentences of your message just leave this: Le 9 oct. 09 à 16:18, Damien Guichard a écrit : Imagine my code is: type color = int let black : color = 0 T

RE: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread David Allsopp
> Le 9 oct. 09 à 16:18, Damien Guichard a écrit : > > > Imagine my code is: >  >  type color = int >  >  let black : color = 0  >  > Then, following your proposition, evaluating black should give me an int rather than a color because int is shorter and therefore nicer. Hmm, I'd say that having OCa

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Yaron Minsky
> - *damien* > > > -- > *En réponse au message* > *de :* Yaron Minsky > *du :* 2009-10-09 11:58:11 > *À :* Andrej Bauer > *CC :* caml-list@yquem.inria.fr > *Sujet :* Re: [Caml-list] Improving OCaml's choice of type to display >

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Stephen Weeks
On Fri, Oct 9, 2009 at 3:33 AM, Andrej Bauer wrote: > On Fri, Oct 9, 2009 at 3:40 AM, Yaron Minsky wrote: >> Choosing shorter names. > > By which you probably mean "the fewest number of dots (module > projections)". That is the rule we used in MLton, breaking ties by most-recently-defined. It w

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-09 Thread Damien Guichard
7;a Mutable(Ord).map end = functor (Ord: Interfaces.Ordered) -> struct include BinaryTree_Keyed.Make(Ord) module Order = Ord type 'a map = 'a tree type 'a foldable = 'a map and fold_key = key type ('a,'b) fold = (key ->

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-10 Thread Damien Guichard
ks du : 2009-10-09 20:14:18 À : caml-list@yquem.inria.fr CC : Sujet : Re: [Caml-list] Improving OCaml's choice of type to display On Fri, Oct 9, 2009 at 3:33 AM, Andrej Bauer wrote: > On Fri, Oct 9, 2009 at 3:40 AM, Yaron Minsky wrote: > > Choosing shorter names. > > By whi

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-11 Thread Damien Guichard
Hi Gilles, The type display routine uses right-associativity of the -> operator as a rewriting rule. Thus ('a -> 'a -> float) and 'a -> ('a -> float) are the same type and are both displayed as 'a -> 'a -> float. The type 'a -> ('a -> float) means the application will be (f x) y which is actu

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-11 Thread Gilles Pirio
Hey Damien Sure, I fully understand that both types are equivalent given the rules governing the application operator. My point was more on the usability side, as the type display is primarily intended at helping the programmer to quickly figure out type mismatch. So I'd think having a display all

Re: [Caml-list] Improving OCaml's choice of type to display

2009-10-11 Thread Lukasz Stafiniak
You need to use a type alias: # type ('a, 'b) func = 'a -> 'b;; type ('a, 'b) func = 'a -> 'b # let castro a = (fun _ -> a : ('a,'b) func);; val castro : 'a -> ('b, 'a) func = This is also how the compiler decides the arity of C functions from "external" declarations, that is, it "counts the arr