Accessing recent additions to the stdlib (`Seq` 4.14) from older versions of OCaml

A while ago I started requiring the seq compatibility package, which independently provides the Seq module that appeared in OCaml 4.07. My assumption then is that it would have been kept on-par with later additions to Stdlib.Seq, so that I could use functions introduced in 4.14 (e.g. Seq.partition) while remaining compatible with earlier versions of OCaml (e.g. 4.03).

But I am unable to find a documentation page for that package, and it seems it hasn’t got a new version since 4.07. Its only version is named base. So it seems my assumption was misled, and the seq package just brings the 4.07 library to pre-4.07 OCaml, and the current library to post-4.07 OCaml.

If that’s so, is there another package I can rely on to gain access to recent additions to the standard library, while still being able to compile with older versions of the language?

Out of curiosity, could you say a few words why you are interested in maintaining compatibility with such an old version of OCaml?

Cheers,
Nicolas

No specific reason beyond letting more users use my library. 4.14 is the very last non-multicore version of OCaml, I find it really is a shame to be so edgy/restrictive while the vast majority of my code is straightforward and could run on much older versions. (I said 4.03 half at random, half because I remember it as somewhat of a landmark for the language itself (match with exception (edited: damn, that was 4.02.3, and I’m seeing now that my beloved let exception appeared in 4.04, so let’s settle on 4.04 from 6 years ago as the sweet spot for the subset of the language I use routinely :wink: ))).

You can try the oseq library. I think most of the new functions were copied from there anyway.

2 Likes

I understand wanting to do it to scratch a technical itch, but do you have a realistic estimate, or any estimate at that, of how many people would be stuck at such old versions? Incidentally, the OPAM repository recently decided to stop testing versions < 4.08, which is what is shipped in Ubuntu 20.04 LTS.

Cheers,
Nicolas

1 Like

If you want to write code against recent stdlib versions and compile it with older versions of OCaml, the project you are looking for is stdcompat from @thierry-martinez. Maintaining this degree of backward-compatibility (whenever possible) is a surprising amount of work, and basically our community can only afford one project doing that – that project is stdcompat. Other compatibility packages are less compatible.

4 Likes

Thank you! oseq and stdcompat are the answers I was looking for. Kudos to Thierry Martinez for maintaining stdcompat, I do conceive how much of a burden it is.

@nojb Which exact version to pick as the minimal supported version is beyond the point of my question. Again I was throwing version numbers at random, for the sake of giving an example. [I’m seeing now that the `Pervasives/Stdlib` renaming was introduced in 4.07 so it wouldn’t be reasonable to target versions older than 4.07. My code turns out to compile fine with 4.07, only with two occurrences of a more recent function. So indeed, 4.07 or 4.08 are better options for a minimal dependency (some of my transitive dependencies require 4.08 anyway).] I assume you agree that there is value in not restricting users to the latest version of OCaml, especially when the reason for doing so is so thin and easily circumvented. (For what I know, I may very well have no user at all, I’d better not add more filters. :wink: )

Sure! I did not mean to criticize your efforts. The reason I asked is because the OCaml community has spent considerable efforts in developing ways to compile “new” code with “old” compilers. I can understand these efforts if they are targeting, say, the “old” versions shipped in mainstream OS distributions, such as Debian. But I’m puzzled about the desire to maintain compilability with versions of OCaml much older than that. It may be that people do it for the sake of it (and that’s fine!), but maybe there are other data points that I ignore that justify such efforts; if so, I would be interested in hearing about them!

Cheers,
Nicolas

3 Likes