<?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/01/75e8db2f49bd671bea94e4a725849785"
  from="Romain Bardou &lt;Romain.Bardou@l...&gt;"
  author="Romain Bardou"
  date="2009-01-21T09:38:41"
  subject="Re: [Caml-list] polymorphic variants, long form"
  prev="2009/01/7b91d248f034cca644d2a27dd0959622"
  next="2009/01/606129155b17b72d64eb1257f4014237"
  prev-in-thread="2009/01/1bb09ae5ed2be27df3bc53c7ed24caed"
  prev-thread="2009/01/fa6c4452c1d8f79eeb50fa71a9e2e430"
  next-thread="2009/01/50a5d1b536ba93ef89f0ef275d1e9286"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="polymorphic variants, long form">
<msg 
  url="2009/01/44166bc88a034e1581bc385cbd06574b"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-20T17:37:35"
  subject="polymorphic variants, long form">
<msg 
  url="2009/01/adf712350410913b2c0a8a14ea5ea8e5"
  from="luc.maranget@i..."
  author="luc.maranget@i..."
  date="2009-01-20T17:39:58"
  subject="Re: [Caml-list] polymorphic variants, long form">
<msg 
  url="2009/01/1bb09ae5ed2be27df3bc53c7ed24caed"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-20T18:04:49"
  subject="Re: [Caml-list] polymorphic variants, long form">
<msg 
  url="2009/01/75e8db2f49bd671bea94e4a725849785"
  from="Romain Bardou &lt;Romain.Bardou@l...&gt;"
  author="Romain Bardou"
  date="2009-01-21T09:38:41"
  subject="Re: [Caml-list] polymorphic variants, long form">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Jacques Carette a écrit :
&gt; Luc Maranget wrote:
&gt;&gt;&gt; What is the proper 'long name' of a polymorphic variant?
&gt;&gt;&gt; module S = struct type a = [`Foo of int] end
&gt;&gt;&gt;
&gt;&gt;&gt; How do I refer to `Foo without opening S?  Both S.`Foo and `S.Foo are 
&gt;&gt;&gt; syntax errors.
&gt;&gt;&gt;
&gt;&gt;&gt; Jacques
&gt;&gt;&gt;     
&gt;&gt;
&gt;&gt; 'Foo does the job, it does not refer to any previous type definition.
&gt;&gt;
&gt;&gt; % ocaml
&gt;&gt;         Objective Caml version 3.11.0
&gt;&gt;
&gt;&gt; # `Foo;;
&gt;&gt; - : [&gt; `Foo ] = `Foo
&gt;&gt;   
&gt; Just  a few minutes after I sent my email, I remembered the answer 
&gt; myself: unlike normal variants, polymorphic variants are not scoped but 
&gt; affect the namespace in a GLOBAL way.  Both extremely convenient and 
&gt; non-modular at the same time.

It does not actually affect the namespace, as there is no namespace for 
polymorphic variants. All variant names can be used, anywhere, and then 
types are inferred. Your type definition S.a does not declares anything 
but S.a, which is just a type abbreviation and could be expanded to 
[`Foo of int] everywhere.

-- 
Romain Bardou

</contents>

</message>

