Back in the day, I remember that Debian had a remarkably flexible standard for version-numbers of packages, and there was (IIRC) a library for comparing them. I see that there’s ocaml-version, but I wonder if there’s something like what I just described, in OCaml ? I suppose that the answer is to take the Debian library and port (or wrapper) it to OCaml, but I figured I’d check first if somebody had done something like this.
Searching opam and googling yielded no results (other than ocaml-version).
do you want the Debian spec or the opam spec of version comparison? If it’s the latter OpamVersionCompare from opam-core is probably what you’re looking for.
opam also does it the debian way, it’s there fairly self-contained and already ripped of from dose3 it seems.
EDIT: @kit-ty-kate does opam diverge from the debian definition?
very slightly, it’s a strict subset AFAIK. The main (only?) thing that opam “removed” from it was the handling of epoch (e.g. 0:2.0.0) because opam never allowed : in version numbers. It used to be in OpamVersionCompare before 2.3.0 but we’ve removed it, in place of a nice 25% speedup.