OCaml needs an arbitrary-precision decimal type

I’ve mentioned this before: What libraries are missing?

But pulling it into a new thread because I have a specific ask: is someone willing to contribute a decimal number implementation to OCaml?

I realize OCaml has historically had a minimalist standard library philosophy, e.g. it’s reasonable to not include a JSON data type, but I believe decimal numbers are a fairly fundamental type especially for business applications. Major industrial language platforms tend to agree:

And even newer ones:

So, I thought I’d bring it up again, as it’s really pretty foundational IMHO.

5 Likes

You’re going at this wrong.

The first step of putting anything in the stdlib is to actually write a library that does it.

So, if you want it, start by writing the library. Publish it, iterate on the design and then maybe propose it. Worse case, you’ll have a good decimal library.

1 Like

Well, I really do believe it should be in the standard library, but I have nothing against starting it as a separate package. In either case, my main question is still: is anyone willing to contribute one?

I’ve kicked off the process of releasing Jane Street’s arbitrary precision decimal type, called Bigdecimal. It should hit github in a few days, I expect.

y

21 Likes

Thank you very much, that is very generous. I’ve been working on a straight-up port of the Python decimal module to OCaml for the past few days, but of course Jane Street’s Bigdecimal will be much more trustworthy than my home-grown effort :slight_smile:

1 Like

Our Bigdecimal library is now live:

It won’t be in the ordinary Opam repo until our next stable release, which is scheduled for early 2021.

16 Likes

I’m trying to find bigdecimal on opam but unless it has a non-obvious name I’m guessing it got overlooked for the v0.14.1 release that was made early 2021?

Is there another release on the horizon where bigdecimal could be included?

v0.14.1 refers to a patch release, which for Jane Street packages, is usually things like fixing compatibility on different platforms or adjusting opam dependencies/constraints and things. The next “stable release” would be v0.15, which hasn’t happened yet, unfortunately.

My alternative may work for your use case: opam - decimal

4 Likes