Question: Given any array in OCaml, I want to get the size of an array element by getting its type first.

```
# let element_type = Array.element_type arr;;
# let element_size = of_int (sizeof element_type);;

```

However, the function Array.element seems not longer available. What else can I do?

Answer: 
A type is not a value, it doesn't have any in-memory representation. Types exist only in the source code and are used by a type checker to statically verify an absence of certain run-time errors. The types are erased from a program during the compilation. There is no runtime representation of a type, as in other languages like Java and C++. 

All values are represented uniformly in OCaml, either as an immediate integer or as a pointer to the heap. Therefore, all values have the same size, that is equal to the size of a machine word. Moreover, strictly speaking, the value representation is implementation specific, and you should not ever access it directly. OCaml is not C, and it takes care of memory representation (and abstracts it). So trying to dig into its internals is a bad idea. 

After a clarification in comments, it became obvious that you were talking about an array type from the Ctypes library. The Ctypes library provides an interface to C language (in both directions) and represent C types as OCaml values. They also provide a `CArray.t` type that represents C Arrays as OCaml values. For that array, you definitely can get the size by utilizing `Ctypes.CArray.element_type` function, e.g.,

```
let sizeof_element arr = sizeof (CArray.element_type arr)

```
OCaml is statically typed. There is (in general) no way to talk about types or their sizes at run time.

On the other hand, nothing prevents a module from creating its own encodings for types. The Bigarray module does this, for example. Possibly that's what you're thinking of.

```
# let a = Bigarray.Array1.create Bigarray.int16_unsigned
            Bigarray.c_layout 100;;
val a :
  (int, Bigarray.int16_unsigned_elt, Bigarray.c_layout)
    Bigarray.Array1.t = <abstr>
# Bigarray.kind_size_in_bytes (Bigarray.Array1.kind a);;
- : int = 2

```