# Type aliases for extensible types

**URL:** <https://discuss.ocaml.org/t/type-aliases-for-extensible-types/8080>\
**Category:** Learning\
**Created:** [June 30, 2021, 4:57pm UTC](https://discuss.ocaml.org/t/type-aliases-for-extensible-types/8080 "2021-06-30T16:57:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrotaru](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vrotaru/32/39_2.png) [@vrotaru](https://discuss.ocaml.org/u/vrotaru)\
**Post date:** [June 30, 2021, 4:57pm UTC](https://discuss.ocaml.org/t/type-aliases-for-extensible-types/8080/1 "2021-06-30T16:57:05Z")

</div>

I was revisiting the shape design thread and I’ve run into something which is not what I would have expected. This is fine:

```auto
module Shape = struct
  type t = ..
end
type shape = Shape.t

module Point = struct
  type t = { x : int; y : int }
end
type point = Point.t

type Shape.t += Point of point

```

But if I replace `Shape.t` with the type alias `shape` like this:

```auto
type shape += Point of point

```

I get the error:

```auto
Error: Type definition shape is not extensible

```

Expected behavior ?

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [June 30, 2021, 5:05pm UTC](https://discuss.ocaml.org/t/type-aliases-for-extensible-types/8080/2 "2021-06-30T17:05:26Z")

</div>

You need to re-export the extensiveness if you want to add new extension constructors using the shape alias:

```ocaml
type t = ..
type a = t = ..
type a+= A
let is_a (x:t) = function A -> true | _ -> false 

```

---

<div class="post-metadata">

**Author:** ![vrotaru](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vrotaru/32/39_2.png) [@vrotaru](https://discuss.ocaml.org/u/vrotaru)\
**Post date:** [June 30, 2021, 5:08pm UTC](https://discuss.ocaml.org/t/type-aliases-for-extensible-types/8080/3 "2021-06-30T17:08:13Z")

</div>

Thanks. A bit unexpected, but probably is mentioned in the manual. And…

Now I’m curious if one can do

```auto
type a = t = ..

```

where `t` is not extensible. Probably not
