There is no thing such as importing in OCaml (it is a notion of a build system), but you can alias a module, e.g.,
module X = Stdlib.Array
you can also open a module namespace to be able to use its definitions without a fully qualified name.
Base and deprecation warnings
So first of all, let me explain what is happening underneath the hood so that you can make your own assessments of the situation
The Janestreet Base library is using a special script during the build time that collects all the definitions from the OCaml standard library and reexports them in the Base module with the deprecated annotation. Their motivation is simple - one shouldn’t mix two standard libraries.
Unfortunately, it is not immediately obvious what you should use since the deprecation warning is just saying that it should not be used with no alternatives provided. Moreover, sometimes there is even no alternative.
In our case, the alternative for the Stdlib’s I/O functions is provided by another Janestreet’s library called
let () = print_endline "Hello, world"
print_endline comes from the
Stdio module and it is now legit. Unfortunately, either by omission or by intention, the
print_int function is not provided by this library. My suggestion, would be to use
printf as a more universal and versatile tool for printing, e.g.,
let () = printf "6 x 9 = %d\n" 42
In general, if you still want to use a deprecated function, then you can use the
[@@@warning] attribute to hush the warnings, e.g., you can just issue
[@@@warning "-3"] in utop (or on toplevel of your program) and won’t see any more deprecation warnings. You can use those attributes on a more fine-granular manner and attach them to particular definitions, e.g., you can re-export
let print_int = Stdlib.print_int [@@warning "-3"]
and then use
print_int without any more warnings.
Array.make, you shall use the
Array.create function instead.