4

For instance, suppose I want to make a type like this (using Dyn_array):

type some_type = SomeConstructor of <Dyn_array of integers>

I'm a little bit lost on how to do this though. Could someone give me an example so I can wrap my head around this?

Jason Baker
  • 192,085
  • 135
  • 376
  • 510

2 Answers2

4

(I don't have batteries installed). DynArray.t is defined already. You just want to specify the type for its free variable and not define a new constructor (what, X of y would do, well, aside from that embedded syntax being illegal),

type some_type = SomeConstructor of integers DynArray.t

If you wanted to leave the type of DynArray free then,

type 'a some_type = SomeConstructor of 'a DynArray.t
nlucaroni
  • 47,556
  • 6
  • 64
  • 86
2

What is the problem ? the syntax ?

Have you tried using an intermediate type ?

type my_dyn = Dyn_Array of int

type some_type = SomeConstructor of my_dyn
LB40
  • 12,041
  • 17
  • 72
  • 107
  • please note that i have batteries installed, but this is what i would do for a regular Stack, and it looks the same (based on the documentation though) – LB40 Dec 01 '09 at 15:21
  • It was the syntax. I actually found an answer for this, but forgot to post the answer here! – Jason Baker Dec 01 '09 at 19:09