<?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/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"
  prev="2009/10/ef5604af293b4607fcb3dec0a899701a"
  next="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  next-in-thread="2009/10/fc32c1d24a699d0d3095b3a2ee159a8e"
  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>
Hi, I've come across a very strange error, and I'm not sure if it is
a bug or a feature.

The following code :
type 'a p = R of 'a t | E of float
    and 'a t = { mutable p : 'a p; c : 'a }
let f =
    let x = sqrt(2.0) in
    fun () -&gt; { c = `A; p = E 0.0 }

generates the error :
  The type of this expression, unit -&gt; _[&gt; `A ] t,
  contains type variables that cannot be generalized

but if I change the x definition to "let x = 2.0 in" then it works.

Another solution is to add a dummy parameter "let f ?(dummy=())" this works
too.
When I say that it works, I mean that the resulting type of f is
 val f : unit -&gt; [&gt; `A ] t
I've seen that in the dev version of ocaml this error has been removed but
the type of f is still "val f : unit -&gt; _[&gt; `A] t" which is not the thing
that I want.

Is that an expected behavior ?

Marc

</contents>

</message>

