I notice several packages are “Compatibility packages” for supporting various versions of ocaml, for instance uchar or seq.
If I’m using OCaml 4.10, In principle I need neither of them, but if I ask opam to install uutf it will install uchar, and if I want lwt it will install seq.
Isn’t there a way to tell opam “install foo only if ocaml version < xx.xx”?
The problem (as I understand it) is that these packages (uutf, lwt, etc) mention the compatibility packages in their build system dependencies, so one cannot just not install them. I agree this is a major pain point with these compatibility packages. Fixing would need some collaboration from the build system.
Interestingly, dune does what is needed when building code withoutocamlfind installed: it “synthetizes” these compatibility packages when the underlying OCaml version provides them. Perhaps this logic could be extended as well to the case when ocamlfind/opamare installed…
Yes. Conditional dependencies can be stated like this:
("ocaml" {>= "4.03.0"} | "result")
Lwt does this for ocaml-syntax-shims.
Note that Dune’s library dependencies can also be made conditional using the OCaml escape hatch for dune files. Lwt already does this to conditionally add future_syntax preprocessing.
As far as I know, there’s no hard blocker in the way of conditionally depending on compatibility packages. I created an Lwt issue last week about doing this for result and seq. (I also have a prototype implementation, but it needs some work.)
Thanks for the clarification @jeremiedimino, I misremembered. In that case, it is enough to make the dependencies conditional in the opam file, indeed.