<?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/fc32c1d24a699d0d3095b3a2ee159a8e"
  from="Jake Donham &lt;jake@d...&gt;"
  author="Jake Donham"
  date="2009-10-27T18:25:12"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants"
  prev="2009/10/cbdd8317941f2f2afc1923fe5247492e"
  next="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  prev-in-thread="2009/10/cbdd8317941f2f2afc1923fe5247492e"
  next-in-thread="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  prev-thread="2009/10/cb62aba28e1f84b31e18b738aad34fde"
  next-thread="2009/10/a542f981ec63f1fb137050f0370eebab"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="A strange typing error with polymorphic variants">
<msg 
  url="2009/10/cbdd8317941f2f2afc1923fe5247492e"
  from="Marc de Falco &lt;marc@d...&gt;"
  author="Marc de Falco"
  date="2009-10-27T10:28:26"
  subject="A strange typing error with polymorphic variants">
<msg 
  url="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  from="Jake Donham &lt;jake@d...&gt;"
  author="Jake Donham"
  date="2009-10-27T18:25:12"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
<msg 
  url="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  from="Vincent Aravantinos &lt;vincent.aravantinos@g...&gt;"
  author="Vincent Aravantinos"
  date="2009-10-27T18:38:04"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
<msg 
  url="2009/10/2e5786ed1315ff7882444d8a62fec6ab"
  from="Vincent Aravantinos &lt;vincent.aravantinos@g...&gt;"
  author="Vincent Aravantinos"
  date="2009-10-27T19:02:25"
  subject="Re: [Caml-list] A strange typing error with polymorphic variants">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Tue, Oct 27, 2009 at 3:28 AM, Marc de Falco &lt;marc@de-falco.fr&gt; wrote:
&gt; Hi, I've come across a very strange error, and I'm not sure if it is
&gt; a bug or a feature.
&gt;
&gt; The following code :
&gt; type 'a p = R of 'a t | E of float
&gt;     and 'a t = { mutable p : 'a p; c : 'a }
&gt; let f =
&gt;     let x = sqrt(2.0) in
&gt;     fun () -&gt; { c = `A; p = E 0.0 }
&gt;
&gt; generates the error :
&gt;   The type of this expression, unit -&gt; _[&gt; `A ] t,
&gt;   contains type variables that cannot be generalized
&gt;
&gt; but if I change the x definition to "let x = 2.0 in" then it works.
&gt;
&gt; Another solution is to add a dummy parameter "let f ?(dummy=())" this works
&gt; too.

I think this is just the value restriction. The type of f is
generalized only if the right hand side is a value (rather than an
expression needing some computation); in your examples the one that
fails is not a value, the others are. It looks like there is a
relaxation to allow let bindings which are themselves values.

Jake

</contents>

</message>

