I found something that I really don't understand when working on a project ocaml.
Suppose I use modules Arrayand the Liststandard OCaml library. They implement a function length, but have different types. In a module, Listthis is its type:
length: a' list -> int
And in the module Arrayit has the type:
length: a' array -> int
But then I wanted you to use both modules in the same module that I implemented using the keyword open:
open List
open Array
When I tried to use the function lengthin the list, at compile time I had a type error.
Since OCaml is a strong statically typed language, I wonder why the compiler did not know that I needed the length function of the list module since I declared that I was using both.
source
share