# Question about typing polymorphic variants

**URL:** <https://discuss.ocaml.org/t/question-about-typing-polymorphic-variants/5428>\
**Category:** Learning\
**Tags:** type-system\
**Created:** [April 2, 2020, 12:48am UTC](https://discuss.ocaml.org/t/question-about-typing-polymorphic-variants/5428 "2020-04-02T00:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfeser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jfeser/32/2093_2.png) [@jfeser](https://discuss.ocaml.org/u/jfeser)\
**Post date:** [April 2, 2020, 12:48am UTC](https://discuss.ocaml.org/t/question-about-typing-polymorphic-variants/5428/1 "2020-04-02T00:48:37Z")

</div>

I’m not sure why the following code fails to type check:

```
module M : sig
  type a = [`A]
  val v : [> a]
end = struct
  type a = [`A]
  type b = B of a
  let v = match B `A with B x -> x
end

Error: Signature mismatch:
   Modules do not match:
     sig type a = [`A] type b = B of a val v : a end
   is not included in
     sig type a = [`A] val v : [> a] end
   Values do not match: val v : a is not included in val v : [> a]

```

Changing `B x` to `B (#a as x)` solves the problem, but I can’t figure out why the annotation should help. Could anyone explain what the type checker is doing here?

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [April 2, 2020, 2:01am UTC](https://discuss.ocaml.org/t/question-about-typing-polymorphic-variants/5428/2 "2020-04-02T02:01:05Z")

</div>

It’s because the pattern `B x` types `x` as (exactly) `a`. It’s the same as if you were to write:

```auto
let a: a = `A
let v = a

```
