Hello Here is the latest OCaml Weekly News, for the week of October 15 to 22, 2024. Table of Contents ───────────────── opam 2.3.0~beta1 Dune dev meeting Wildcard expansion on Windows OCamlformat and GitHub actions New vs. Old OCaml Academic Users Page Survey New vs. Old OCaml Industrial Users Page Eliom 11 and Ocsigen Start 7 Other OCaml News Old CWN opam 2.3.0~beta1 ════════════════ Archive: Kate announced ────────────── We're happy to announce the first beta release of opam 2.3.0. As we're closing on the final release of opam 2.3.0, we'd be happy for people to test this beta and report any regression. What's new? ╌╌╌╌╌╌╌╌╌╌╌ This release consists mostly in regression fixes compared to 2.3.0~alpha1: • Fix a regression where pinning a local source repository containing initialized git submodules would cause a failure when fetching the package. ([#5809]) • Fix a regression which would make opam crash on platforms such as OpenBSD. ([#6215]) • Fix the internal cache of installed packages, which was storing the wrong version of the opam file after a build failure. ([#6213]) • Fix a regression in lint W59 with local urls that are not archives. ([#6218]) A couple of other improvements were made and bugs were fixed. :open_book: You can read our [blog post] for more information about these changes and more, and for even more details you can take a look at the [release note] or the [changelog]. [#5809] [#6215] [#6213] [#6218] [blog post] [release note] [changelog] Try it! ╌╌╌╌╌╌╌ The upgrade instructions are pretty much the same: For Unix systems ┌──── │ bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh) --version 2.3.0~beta1" └──── or from PowerShell for Windows systems ┌──── │ Invoke-Expression "& { $(Invoke-RestMethod https://opam.ocaml.org/install.ps1) } -Version 2.3.0~beta1" └──── Please report any issues to [the bug-tracker]. [the bug-tracker] Dune dev meeting ════════════════ Archive: Steve Sherratt announced ──────────────────────── Notes from today's dune-dev meeting are [here] [here] Wildcard expansion on Windows ═════════════════════════════ Archive: Benjamin Sigonneau announced ──────────────────────────── While implementing a small CLI tool, I ran into a somehow undocumented feature of the Ocaml compiler: it automatically expands wildcards before doing anything else. Which proved to be a problem. This post serves three different goals: • give some visibility, in case someone else run into this issue in the future • expose a possible workaround • ask the community if there is a better way™ to solve this Context ╌╌╌╌╌╌╌ My tool uses `Cmdliner' for CLI args processing, and needs to handle basic wildcard processing for one of its options, eg. it should handle `mytool.exe -x *.ml'. This would get expanded to `mytool.exe -x a.ml b.ml c.ml' which Cmdliner cannot handle. Under any common Unix shell, this is not a problem: we just have to escape the star character with eg. `mytool.exe -x \*.ml', have mytool handle the expansion itself and we're all set. So far, so good. Then came Windows. Whatever I would do, it seemed like there was no way of preventing that wildcard to be expanded. I learned that on Windows, the calling program was responsible for dealing with wildcards, not the shell. After some digging, the root cause of this behaviour was found in the ocaml runtime itself, in [`runtime/main.c']: ┌──── │ int main_os(int argc, char_os **argv) │ { │ #ifdef _WIN32 │ /* Expand wildcards and diversions in command line */ │ caml_expand_command_line(&argc, &argv); │ #endif │ │ /* [...] */ │ } └──── After a bit of history digging, it turns out this behaviour dates back from the very early stages of the Ocaml compiler, see [this commit] by Xavier Leroy from… 1996! [`runtime/main.c'] [this commit] Workaround ╌╌╌╌╌╌╌╌╌╌ The `runtime/main.c' file gives a hint on how to work around this: ┌──── │ /* Main entry point (can be overridden by a user-provided main() │ function that calls caml_main() later). */ └──── So the most elegant workaround I could find was to create a copy of the `main.c' file inside the source tree of mytool and comment out the call to `caml_expand_command_line'. Then it was a matter of compiling and linking everything altogether. I use `dune' to compile `mytool.exe', and after a lot of trial-and-error, I found out it could handle this very easily with the `foreign_stubs' stanza: ┌──── │ (executable │ (name mytool) │ (foreign_stubs (language c) (names main)) │ ; ... │ ) └──── Minimal working example ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ I opened a Github repository containing a minimal project featuring a custom entry point so that command-line arguments expansion does not happen on Windows. See: Open Questions ╌╌╌╌╌╌╌╌╌╌╌╌╌╌ • The root cause of this issue was introduced almost 30 years ago. How come no one on the Internets seem to have run into a similar issue? • Why was this behaviour introduced in the first place? I suspect it may have make it easier to setup a Windows toolchain back then, but that's just wild speculation. • Is this behaviour still needed, or could we get rid of it? • Should this be more wildly documented, and if so, where? The ocaml compiler docs and the dune docs could probably benefit from a small paragraph on how to override the default entry point. OCamlformat and GitHub actions ══════════════════════════════ Archive: Hannes Mehnert announced ──────────────────────── a small announcement for those using OCamlformat in their projects: if you find the burden on external contributors very high, and always express "please run ocamlformat on your PR" – we've been in the same boat. We developed a GitHub action which automatically runs OCamlformat and pushes that on the PR. No need for contributors to remember running OCamlformat, no need for "OCaml-CI" to fail since ocamlformat run diverges. If you're interested, take a look at – please note that we use `find . -name \*ml -maxdepth 1' – depending on your project you may be able to run `dune bu @fmt --auto' (or need a slightly different `find' to look deeper or also for mli files). Happy to share this action which turned out to be tremendously useful for some of our projects. New vs. Old OCaml Academic Users Page Survey ════════════════════════════════════════════ Archive: Claire Vandenberghe announced ───────────────────────────── We've recently *redesigned the OCaml Academic Users page* and would love to *get your feedback* to ensure it’s as helpful as possible. You can view both versions here: • New page:[ ocaml.org/academic-users] • Old page:[ staging.ocaml.org/academic-users] As a teacher, student expert or beginner developer using OCaml, we’d greatly appreciate your insights! Participate in the survey here: [https://docs.google.com/forms/d/e/1FAIpQLSfc9qPR16deJ6VeVmXGXPVO4e3wZ9ZVIYiWrS4f1RZsqcXxwQ/viewform?usp=sf_link] or we can discuss this topic below :) Do you find the new page more useful and relevant for your academic needs compared to the old one? If so, why? Is there any information missing or anything you’d suggest improving on the new page? Your feedback is incredibly valuable to us as we work to improve the experience for the OCaml community. Thank you in advance! [ ocaml.org/academic-users] [ staging.ocaml.org/academic-users] [https://docs.google.com/forms/d/e/1FAIpQLSfc9qPR16deJ6VeVmXGXPVO4e3wZ9ZVIYiWrS4f1RZsqcXxwQ/viewform?usp=sf_link] New vs. Old OCaml Industrial Users Page ═══════════════════════════════════════ Archive: Claire Vandenberghe announced ───────────────────────────── We've recently redesigned the *OCaml Industrial Users pages* and would love to get *your feedback* to ensure it’s as helpful as possible. You can view both versions here: • New: • Old: As an expert or beginner developer using OCaml, we’d greatly appreciate your insights! You can also participate to the survey here: or we can discuss this topic below :) Do you find the new page more useful and relevant for industrial needs compared to the old one? If so, why? Is there any information missing or anything you’d suggest improving on the new page? Your feedback is incredibly valuable to us as we work to improve the experience for the OCaml community. Thank you in advance! Eliom 11 and Ocsigen Start 7 ════════════════════════════ Archive: Vincent Balat announced ─────────────────────── Eliom 11 and Ocsigen Start 7 have been released a few weeks ago. These versions follow the recent release of Ocsigen Server 6 and leverage its new configuration API to make it easier to use it as a library, without a configuration file. Here is an example of a simple OCaml app generating a Web page from server side (and serving static pages from directory `"local/var/www/mysite"'): ┌──── │ let f _ () = │ Lwt.return │ Eliom_content.Html.F.(html (head (title (txt "")) []) │ (body [h1 [txt "Hello"]])) │ │ let myservice = │ Eliom_service.create │ ~path:(Eliom_service.Path []) │ ~meth:(Eliom_service.Get Eliom_parameter.any) │ () │ │ let () = Eliom_registration.Html.register ~service:myservice f │ │ let () = Ocsigen_server.start │ [ Ocsigen_server.host │ [ Staticmod.run ~dir:"local/var/www/mysite" () │ ; Eliom.run () ] ] └──── To use it, just install Eliom and your favorite version of Ocipersist, then create a new Dune project: ┌──── │ opam install ocsipersist-sqlite-config eliom │ dune init project mysite └──── Put the code above in file `bin/mysite.ml' Update file `bin/dune': ┌──── │ (executable │ (public_name mysite) │ (name main) │ (libraries │ ocsigenserver │ ocsigenserver.ext.staticmod │ ocsipersist-sqlite │ eliom.server)) └──── Build and execute: ┌──── │ dune exec mysite └──── Open URL `http://localhost:8080/'. Ocsigen Start's application template has been updated to support both the use as an executable or as a library (lynked dynamically from the server's config file). Links: • [Ocsigen] • [Github] [Ocsigen] [Github] Other OCaml News ════════════════ >From the ocaml.org blog ─────────────────────── Here are links from many OCaml blogs aggregated at [the ocaml.org blog]. • [Developer education at Jane Street] • [Dune Developer Preview: Installing The OCaml Compiler With Dune Package Management] • [Upcoming OCaml Events] [the ocaml.org blog] [Developer education at Jane Street] [Dune Developer Preview: Installing The OCaml Compiler With Dune Package Management] [Upcoming OCaml Events] Old CWN ═══════ If you happen to miss a CWN, you can [send me a message] and I'll mail it to you, or go take a look at [the archive] or the [RSS feed of the archives]. If you also wish to receive it every week by mail, you may subscribe to the [caml-list]. [Alan Schmitt] [send me a message] [the archive] [RSS feed of the archives] [caml-list] [Alan Schmitt]