title: How to match private polymorphic variant type outside of containing module?
body: <p>I can close the ability to create an instance of variant type outside the containing module with a <code>private</code> keyword.</p>
  <pre class="lang-ml prettyprint-override"><code>module Ordinary : sig
    type t = private X | Y
    val x : t
  end = struct 
    type t = X | Y 
    let x = X
  end
  </code></pre>
  <p>I can't create instances of <code>Ordinary.t</code> and the following example is uncompilable:</p>
  <pre class="lang-ml prettyprint-override"><code>let f x = if x = Ordinary.X then 1 else 2
  </code></pre>
  <blockquote>
  <p>Error: Cannot create values of the private type Ordinary.t</p>
  </blockquote>
  <p>But I can match <code>Ordinary.t</code> and the following function works fine:</p>
  <pre class="lang-ml prettyprint-override"><code>let f a = function
    | Ordinary.X -&gt; 1
    | Ordinary.Y -&gt; 2
  </code></pre>
  <p>For me, it is logically correct and I expect the same behavior from polymorphic variants. I created the analogical module for this case too.</p>
  <pre class="lang-ml prettyprint-override"><code>module Polymorphic : sig
    type t = private [`X | `Y]
    val x : t
  end = struct 
    type t = [`X | `Y]
    let x = `X
  end
  </code></pre>
  <p>But I can't match <code>Polymorphic.t</code>. All my tries with error messages are shown below:</p>
  <pre class="lang-ml prettyprint-override"><code>let g a = 
    match a with
    | `X -&gt; 1 
    | `Y -&gt; 2
      
  let x = g Polymorphic.x
  </code></pre>
  <blockquote>
  <pre class="lang-ml prettyprint-override"><code>let x = g Polymorphic.x
            ^^^^^^^^^^^^^
  </code></pre>
  <p>Error: This expression has type Polymorphic.t but an expression was expected of type
  [&lt; `X | `Y ]</p>
  </blockquote>
  <pre class="lang-ml prettyprint-override"><code>let x = match Polymorphic.x with
    | `X -&gt; 1
    | `Y -&gt; 2 
  </code></pre>
  <blockquote>
  <pre class="lang-ml prettyprint-override"><code>| `X -&gt; 1
    ^^
  </code></pre>
  <p>Error: This pattern matches values of type [? `X ]
  but a pattern was expected which matches values of type Polymorphic.t</p>
  </blockquote>
  <pre class="lang-ml prettyprint-override"><code>let x = match Polymorphic.x with
    | Polymorphic.`X -&gt; 1
    | Polymorphic.`Y -&gt; 2 
  </code></pre>
  <blockquote>
  <pre class="lang-ml prettyprint-override"><code>| Polymorphic.`X
                ^
  </code></pre>
  <p>Error: Syntax error</p>
  </blockquote>
  <pre class="lang-ml prettyprint-override"><code>let x = 
    let open Polymorphic in
    match x with
    | `X -&gt; 1
    | `Y -&gt; 2
  </code></pre>
  <blockquote>
  <pre class="lang-ml prettyprint-override"><code>| `X -&gt; 1
    ^^
  </code></pre>
  <p>Error: This pattern matches values of type [? `X ]
  but a pattern was expected which matches values of type Polymorphic.t</p>
  </blockquote>
  <p>Is it possible to match the private polymorphic variant type outside of the declaration container?<br />
  If it is - How? If it is not - Why?</p>