How do I make a type that uses Batteries' Dyn_array in OCaml?
Question
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?
Solution
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
OTHER TIPS
(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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow