You can not. This is a design choice. Many languages ββallow null. The problem with this approach is that the values ββare zero when the programmer does not expect this, or the code should be studded with checking each input value for zeros.
OCaml uses an approach that, if the value can be null, then it should be explicitly marked as such. This is done with the option type:
match value with | None -> failwith "Empty" | Some value -> (* do something *)
However, if you replace it directly in your program, if it is not compiled, because OCaml will detect that the "value" cannot actually be null. Whatever is created needs to be updated to indicate when it returns "null":
let safe_divide numerator denominator = if denominator <> 0. then Some (numerator /. denominator) else None (* division by zero *)
source share