ocamllibrariesbigintegerutopocaml-dune

Ocaml utop does not (but does) recognise Big_int


I have some code that uses the module Big_int, like in:

open Big_int;;
Big_int.gcd_big_int 5 6;;

However, when I compile this with utop dune utop --release (I use release to avoid some warnings), then I get this error:

Error: Required module `Big_int' is unavailable

I have read about it and I have read (https://groups.google.com/g/felix-language/c/1CfHgpe9zps?pli=1) that 'Big_int is no longer part of the OCaml distribution. It was replaced by Zarith'. Well, I know that, but also that I can still use Big_int.

How do I know it? The point is that if I start utop with any other file that has no errors, and once inside I open Big_int, then it does not regret:

utop # open Big_int;;

Once there, it autocompletes my Big_int., like in Big_int.add_big_int. So there Big_int is there somewhere and it is recognised (VSCode also autocompletes it).

There is something I am not understanding. Any help?


Solution

  • For compatibility reasons, the binary files for the num library are still installed (in 2021) in the compiler directory. This is what you are seeing in utop.

    However, num is deprecated in favor of Zarith.

    If for some imperious needs, you need to use num, you need to declare it as a dependency in your project's dune file before using it with dune utop.