<?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="2003/12/af83cb0ff0838dd0dc048fae73cb32e2"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-12-15T12:11:02"
  subject="Re: [Caml-list] polymorphic function not recognised as such"
  prev="2003/12/d1b02bef80190b6a892c1eb4d2c74bff"
  next="2003/12/0652bd6b7d5bfddc432dff9fee4000eb"
  prev-in-thread="2003/12/22a7ccbbbae6a7e18cdc45f3ea6dabc4"
  prev-thread="2003/12/c9409b63462d80cc0a4b0355adf1e0b0"
  next-thread="2003/12/2539c2c91c0d6a1135376d2e330ca702"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] polymorphic function not recognised as such">
<msg 
  url="2003/12/4254f003f0a5d186c5e7a8b31e551054"
  from="Benjamin Geer &lt;ben@s...&gt;"
  author="Benjamin Geer"
  date="2003-12-14T19:14:17"
  subject="[Caml-list] polymorphic function not recognised as such">
<msg 
  url="2003/12/eac46552a7b577d9a89a07fc38092a70"
  from="Jean-Baptiste Rouquier &lt;jean-baptiste.rouquier@e...&gt;"
  author="Jean-Baptiste Rouquier"
  date="2003-12-14T20:06:35"
  subject="Re: [Caml-list] polymorphic function not recognised as such">
</msg>
<msg 
  url="2003/12/1380e77c5d5f6a5e2966de692bdc968a"
  from="Benjamin Geer &lt;ben@s...&gt;"
  author="Benjamin Geer"
  date="2003-12-14T21:38:31"
  subject="Re: [Caml-list] polymorphic function not recognised as such">
<msg 
  url="2003/12/22a7ccbbbae6a7e18cdc45f3ea6dabc4"
  from="Olivier Andrieu &lt;andrieu@i...&gt;"
  author="Olivier Andrieu"
  date="2003-12-14T22:06:18"
  subject="Re: [Caml-list] polymorphic function not recognised as such">
</msg>
<msg 
  url="2003/12/af83cb0ff0838dd0dc048fae73cb32e2"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-12-15T12:11:02"
  subject="Re: [Caml-list] polymorphic function not recognised as such">
</msg>
</msg>
</msg>
</thread>

<contents>
On Sun, Dec 14, 2003 at 09:38:24PM +0000, Benjamin Geer wrote:
&gt; Jean-Baptiste Rouquier wrote:
&gt; &gt;   compare_things : thing -&gt; thing -&gt; ('a -&gt; 'a -&gt; bool) -&gt; bool
&gt; &gt;doesn't mean that comparison_fun has to be polymorphic, but it means 
&gt; &gt;that any function with type ('a -&gt; 'a -&gt; bool), where 'a is any type, is 
&gt; &gt;acceptable. For instance, the type checker would accept a function of 
&gt; &gt;the type (char -&gt; char -&gt; bool).
&gt; 
&gt; OK, but it seems that the type checker has inferred the type of 
&gt; comparison_fun just by looking at its first use in compare_things, and 
&gt; has decided that it must be monomorphic; this is an incorrect inference. 
&gt;  My naive impression is that if the type checker was willing to accept 
&gt; both uses of comparison_fun as valid (or perhaps if it also looked at 
&gt; the places where compare_things is called), it would conclude that 
&gt; comparison_fun does indeed have to be polymorphic.  In that case, I 
&gt; would get a compile error if I tried to pass a non-polymorphic function 
&gt; to compare_things.  Would this be this asking too much?  (I suspect the 
&gt; answer is yes; I'm just curious...)

Polymorphism in ML is flat, that is all type variables are quantified
before the function, not in the arguments. The type ('a -&gt; foo) -&gt; bar
means forall 'a. ('a -&gt; foo) -&gt; bar, and not (forall 'a. 'a -&gt; foo) -&gt; bar.

This is one of the costs of type inference.

In OCaml you can simulate deep polymorphism with polymorphic records
(but you have to write explicit type then).

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}&gt;+++ h

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

