Reputation: 4425
I would like to define a record type with one member being of types array, like this :
type h = {x:int; y:int; pic : Array of int};;
This gives a syntax error at of
location :
type h = {x:int; y:int; pic : Array *of* int};;
Now, if I am using an intermediate type to name Array of int
, it works:
type a = Array of int;;
type h = {x:int; y:int; pic : a};;
Is it a defect or do I miss sth ? (my ocaml version is 4.05.0)
Then, once type h
is defined I cannot use it :
let n = {x=0;y=0;pic=[| 0 |]};;
I got the error :
Error: This expression has type 'a array but an expression was expected of type
a
Upvotes: 2
Views: 349
Reputation: 29106
The type of an array of int
s is int array
. type a = Array of int
defines a variant with a single constructor Array
that takes a payload of type int
.
Upvotes: 3