Platform Newsletter: July 2023

Welcome to the fourth installment of the OCaml Platform newsletter!

This edition brings the latest improvements made in July to improve the OCaml developer experience with the OCaml Platform. As in the previous updates, the newsletter features the development workflows currently being explored or enhanced.

This issue ended up a bit shorter than the previous ones, as we're entering summertime in Europe. Still, this month saw some great progress on support for package management in Dune, with only a few remaining blockers to build simple opam packages. We also saw the release of the second alpha of the most anticipated opam 2.2, which comes with an automated installation of Cygwin on Windows, allowing users to install a complete development environment using opam's installation script alone!

Releases

Here are all the new versions of Platform tools that were released this month. Have a look at the OCaml Changelog to read release announcements!

Building Packages

[Dune] Exploring Package Management in Dune

Contributors: @rgrinberg (Tarides), @Leonidas-from-XIV (Tarides), @gridbugs (Tarides), @kit-ty-kate (Tarides)

In July, the Dune Package Management team worked on automatically downloading the opam-repository to ensure it is readily available for locking when no other source of opam-repository is specified.

The Dune version of opam substs support was implemented, and the variable environment was enhanced when expanding opam package filters in the solver.

Support for system variables was also added, which can be read from the workspace file or inferred from the current system. Notably, unset system variables are now treated as wildcards by the solver, allowing the generation of a single lockdir suitable for a range of systems. This change eliminates the need for different lockdirs for various systems, such as macOS and Linux.

Activities:

  • Add field to indicate OCaml package -- ocaml/dune#8079
  • Created issues to track remaining work building opam packages in Dune, along with a meta issue
  • Conditional dependencies in lockdir -- ocaml/dune#8050
    • Chain of commits ready to go into new PRs once this is merged, which will extend this to allow users to place constraints on system env vars in build contexts and to solve for a range of systems at once. For example, this can be used to generate a lockdir that works on both macOS and Linux or generate a lockdir for macOS while running on a Linux machine.
  • Solver can solve for multiple environments in single lockdir -- ocaml/dune#8188
    • This will allow users to use a single lockdir across multiple different environments (e.g., different operating systems).
  • Implement automatic download of opam-repository with the option to use an existing folder or customising the default URL (defaulting to the opam-repository tarball), thus removing the need to piggyback on the opam-repository of a switch and removing support for it, somewhat simplifying the way the 0install solver is run -- ocaml/dune#8105
  • Work on implementing the substitution support from opam as part of Dune by hooking up the functions from the opam API with the Dune rules -- ocaml/dune#8225
  • Creation of files from .in templates to match the opam substs field/feature -- ocaml/dune#8225
  • Progress on creating a variable environment for package solving:

[opam] Native Support for Windows in opam 2.2

Contributors: @rjbou (OCamlPro), @kit-ty-kate (Tarides), @dra27 (Tarides), @AltGr (OCamlPro)

The first alpha of the highly-anticipated opam 2.2 was released last month. The second alpha of opam 2.2 was released this month.

While the first alpha introduced native Windows compatibility, the second alpha offers simpler initialisation for Windows, eliminating the dependency on a preexisting Cygwin UNIX-like environment. Instead, opam now offers an embedded, fully-managed Cygwin install during initialisation.

Have a look at the release announcement for more details, and join the discussion to share your feedback on Discuss.

Activities:

  • Make opam init internally install Cygwin automatically by default instead of asking the user to install it manually -- opam#5545

[Dune] dune monitor: Connect to a Running Dune build

Contributors: @Alizter

This month, @Alizter started working on a new dune monitor command that connects to a Dune build that's running in watch mode (via Dune RPC) and behaves as if you executed dune build -w.

In the future, the plan is to merge dune monitor into the dune build command, so running a build will spawn an RPC server by default and any subsequent build will connect to the RPC server to display the build information.

This is especially exciting in the context of Dune package management. Editors will be able to connect to a running Dune RPC server (directly or through OCaml LSP) to provide the relevant editors' features. With dune monitor, there will not be limitations in the number of editors you can open for the same project!

With recent work on Dune Terminal UI, expect the experience of running multiple build commands to improve quite a lot in the near future!

Generating Documentation

[odoc] Add Search Capabilities to odoc

Contributors: @panglesd (Tarides), @EmileTrotignon (Tarides), @trefis (Tarides)

The odoc team continued to make progress on generating a search index from odoc and adding search capabilities to the HTML backend.

Some issues have been found during testing and have been addressed, and Sherlodoc was updated to be compatible with the latest version of odoc, which now provides basic support for assets used to select the search JavaScript script file.

Activities:

[odoc] Syntax for Images and Assets in odoc

Contributors: @panglesd (Tarides)

As part of the work to make odoc suitable to create rich manuals, the odoc team started working on adding special support for images and assets! This initiative will bring image support to OCaml.org's central package documentation.

In the upcoming weeks, the syntax and design will be discussed in the RFC that was open in July, with implementation set to begin as soon as there is a consensus on the design.

Activities:

  • Implemented asset references (using the asset-* qualification in references), as well as their resolving (see branch).
  • Opened an issue to discuss the syntax for images, with an initial proposal. -- ocaml/odoc#985

Editing and Refactoring Code

[Merlin] Support for Project-Wide References in Merlin

Contributors: @voodoos (Tarides), @let-def (Tarides)

This month, work on project-wide references focused on improving alias handling, fixing issues related to UID, and enhancing the behavior with modules and constructors.

Every Merlin test is now passing (:tada:!), so the team intends to focus on getting the compiler patches upstreamed, which will in turn unlock the upstreaming of the rest of the stack (i.e., Merlin, Dune, and OCaml LSP).

Activities:

[Merlin] Improving Merlin's Performance

Contributed by: @pitag-ha (Tarides), @3Rafal (Tarides), @voodoos (Tarides), @let-def (Tarides)

Last month, we reported that the PR to continuously benchmark Merlin was merged. The next stage involved implementing a fuzzy-testing PR to monitor behavior regression. In July, an RFC of this behaviour regression CI, accompanied by an initial implementation, was introduced to discuss the design's trade-offs.

Upon merging, the foundational work on Merlin's CI system will be complete, and the Merlin team intends to shift their focus to performance optimisations.

Activities: