<?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/eae2ed4acac0d4e91763455776c1749d"
  from="Lukasz Stafiniak &lt;lukstafi@g...&gt;"
  author="Lukasz Stafiniak"
  date="2009-10-11T22:16:13"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display"
  prev="2009/10/a61931cf0c006bcdd12f4acb487f3499"
  next="2009/10/c8c2413a8570c524939f1b4a4f7690a6"
  prev-in-thread="2009/10/a61931cf0c006bcdd12f4acb487f3499"
  prev-thread="2009/10/c17c0e6481804fa9249bde60a00584c2"
  next-thread="2009/10/c8c2413a8570c524939f1b4a4f7690a6"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/f9ed5ca6f49cf9e3f55ad08a4f82f4cb"
  from="Damien Guichard &lt;alphablock@o...&gt;"
  author="Damien Guichard"
  date="2009-10-11T21:17:40"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/a61931cf0c006bcdd12f4acb487f3499"
  from="Gilles Pirio &lt;gilles.ocaml@g...&gt;"
  author="Gilles Pirio"
  date="2009-10-11T21:46:11"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
<msg 
  url="2009/10/eae2ed4acac0d4e91763455776c1749d"
  from="Lukasz Stafiniak &lt;lukstafi@g...&gt;"
  author="Lukasz Stafiniak"
  date="2009-10-11T22:16:13"
  subject="Re: [Caml-list] Improving OCaml&apos;s choice of type to display">
</msg>
</msg>
</msg>
</thread>

<contents>
You need to use a type alias:

# type ('a, 'b) func = 'a -&gt; 'b;;
type ('a, 'b) func = 'a -&gt; 'b
# let castro a = (fun _ -&gt; a : ('a,'b) func);;
val castro : 'a -&gt; ('b, 'a) func = &lt;fun&gt;

This is also how the compiler decides the arity of C functions from
"external" declarations, that is, it "counts the arrows" without
unfolding type aliases.

On Sun, Oct 11, 2009 at 11:46 PM, Gilles Pirio
&lt;gilles.ocaml@googlemail.com&gt; wrote:
&gt; Hey Damien
&gt;
&gt; Sure, I fully understand that both types are equivalent given the rules
&gt; governing the application operator. My point was more on the usability side,
&gt; as the type display is primarily intended at helping the programmer to
&gt; quickly figure out type mismatch. So I'd think having a display allowing to
&gt; quickly distinguish between the noe and castro functions below would be a
&gt; good thing, especially for beginners. I've been using ocaml for a few years
&gt; now, and I have to say that it's not a major issue any more - just wanted to
&gt; give some feedback about this.
&gt;
&gt; Thanks
&gt; Gilles
&gt;
&gt;
&gt; # let noe a b = a;;
&gt; val noe : 'a -&gt; 'b -&gt; 'a = &lt;fun&gt;
&gt; # let castro a = fun _ -&gt; a;;
&gt; val castro : 'a -&gt; 'b -&gt; 'a = &lt;fun&gt;
&gt;

</contents>

</message>

