<?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/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"
  prev="2009/10/11ac90cafeaac1ff5bfbc5c8bae87c55"
  next="2009/10/a542f981ec63f1fb137050f0370eebab"
  prev-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>
Oops, I pushed "send" button too early.

Le 27 oct. 09 à 19:38, Vincent Aravantinos a écrit :

&gt; Le 27 oct. 09 à 19:24, Jake Donham a écrit :
&gt;
&gt;&gt; On Tue, Oct 27, 2009 at 3:28 AM, Marc de Falco &lt;marc@de-falco.fr&gt;  
&gt;&gt; wrote:
&gt;&gt;&gt; The following code :
&gt;&gt;&gt; type 'a p = R of 'a t | E of float
&gt;&gt;&gt;    and 'a t = { mutable p : 'a p; c : 'a }
&gt;&gt;&gt; let f =
&gt;&gt;&gt;    let x = sqrt(2.0) in
&gt;&gt;&gt;    fun () -&gt; { c = `A; p = E 0.0 }
&gt;&gt;&gt;
&gt;&gt;&gt; generates the error :
&gt;&gt;&gt;  The type of this expression, unit -&gt; _[&gt; `A ] t,
&gt;&gt;&gt;  contains type variables that cannot be generalized
&gt;&gt;&gt;
&gt;&gt;&gt; but if I change the x definition to "let x = 2.0 in" then it works.
&gt;&gt;
&gt;&gt; I think this is just the value restriction. The type of f is
&gt;&gt; generalized only if the right hand side is a value (rather than an
&gt;&gt; expression needing some computation); in your examples the one that
&gt;&gt; fails is not a value, the others are. It looks like there is a
&gt;&gt; relaxation to allow let bindings which are themselves values.
&gt;
&gt; With the -dlambda option, the "sqrt(2.0)" version gives:
&gt;  (let
&gt;    (f/92
&gt;       (let (x/93 (caml_sqrt_float 2.0))
&gt;         (function param/94 (makemutable 0 [1: 0.0] 65a))))
&gt;
&gt; whereas the "2.0" version gives:
&gt;  (let (f/96 (let (x/97 2.0) (function param/98 (makemutable 0 [1:  
&gt; 0.0] 65a))))
&gt;
&gt; i.e. this last version is inlined.

Do you think this can give a hint?

V.
</contents>

</message>

