Platform Newsletter: June-August 2024

Welcome to the twelfth edition of the OCaml Platform newsletter!

In this June-August 2024 edition, we are excited to bring you the latest on the OCaml Platform, continuing our tradition of highlighting recent developments as seen in previous editions. To understand the direction we're headed, especially regarding development workflows and user experience improvements, check out our roadmap.

Highlights:

  • Dune package management soon in public beta: Developer Preview Program expands with 60+ interview sign-ups (16 conducted so far), NPS soaring from +9 to +28! Public beta coming soon with exciting features like automatic dependency locking and dev tool management. See it in action!
  • Opam 2.2 is out: Native Windows support is here! Seamless setup with opam init, opam-repository compatible with Windows. OCaml on Windows is now a reality.
  • Odoc 3.0 gets close to a release: New features like global sidebars and media support are ready in odoc. Integration with Dune and OCaml.org pipeline in progress - get ready to test the new documentation experience soon! Check out the RFCs.
  • Project-wide references is live: Merlin 5.1 and OCaml LSP 1.18.0 bring powerful code navigation to your editor. Built on years of compiler work, it's a game-changer for large codebases.
  • Starting to bridge the gap between Merlin and OCaml LSP: New LSP queries for type enclosing, documentation, and more. We’re working towards consistent, feature-rich experience across all editors powered by OCaml LSP.

Releases:

Dune Package Management (W4)

Contributed by: @rgrinberg (Jane Street), @Leonidas (Tarides), @gridbugs (Tarides), @maiste (Tarides), @ElectreAAS (Tarides), @moyodiallo (Tarides), @Alizter

Synopsis: Integrating package management into Dune, making it the sole tool needed for OCaml development. This unification eliminates installation time (just download Dune's pre-built binary), automates external tool management (e.g., for dune fmt or dune ocamllsp), and significantly reduces build times through caching (packages and compiler are built only once across projects).

Summary:

Following our announcement of reaching the Minimal Viable Product (MVP) stage for Dune's package management in the last newsletter, we've made substantial progress on our stated goals. As promised, we've shifted our focus from prototyping to user testing and refining the developer experience (DX).

The Developer Preview Program (see latest update) has expanded significantly from its early stages. We've conducted approximately 16 developer interviews out of the 60 sign ups, representing a diverse cross-section of the OCaml community. The interviewees include both newcomers and experienced OCaml users. Notably, about 40% of participants have over 3 years of OCaml experience, while 35% are relative newcomers with less than a year of experience. The majority come from Linux and macOS environments, with participants representing various sectors including tech companies, research institutions, and independent developers.

These sessions have provided crucial feedback and driven improvements. This extensive user testing has paid off, with the Net Promoter Score jumping from +9 to an estimated +28 - a clear sign that the community is excited about the improvements we've made.

Key developments since the last update include:

  • A nightly binary distribution of Dune with package management enabled, which will be made available publicly in the coming weeks.
  • We started work on automated handling of developer tools (ocamlformat, ocamllsp, odoc) -- users will be able run dune fmt, or dune ocamllsp, and Dune will take care of installing OCamlFormat and OCaml LSP automatically if they are not available.
  • Implementation of automatic dependency locking when project’s dependency changes -- you can now run Dune in watch mode and let it install your dependencies without any intervention after updating your dune-project
  • We’ve enabled Dune cache by default, which works with your package dependencies. With this change, Dune will not recompile dependencies more than once when building new projects, including the compiler!

The team has moved beyond just testing with OCaml.org and Bonsai, now conducting broader compatibility tests across the opam repository. Initial results show about 50% of packages can be authored using Dune with package management, with ongoing efforts to increase the coverage (we expect resolution of a few issues on a select few foundational packages to significantly increase that percentage).

In line with the commitment to prepare for a first release, the team plans to launch a public beta in the coming weeks. This marks a significant step from our current private Developer Preview testing with selected beta testers, to a broader community release.

Stay tuned for the upcoming announcement, and in the meantime, have a look a the demos and some enthusiastic messages from beta testers:

Activities:

Native Support for Windows in opam 2.2 (W5)

Contributed by: @rjbou (OCamlPro), @kit-ty-kate (Ahrefs), @dra27 (Tarides), @AltGr (OCamlPro)

Synopsis: Releasing opam 2.2 with native Windows support to enhance OCaml's viability on Windows, making the official opam-repository usable on Windows and encouraging more Windows-friendly packages.

Summary:

The release of opam 2.2.0, announced on Discuss early July, marks a significant milestone for the OCaml ecosystem. This version brings native support for both the opam client and compiler packages in opam-repository on Windows, opening new possibilities for OCaml development on this platform.

opam 2.2.0 officially supports Cygwin and is compatible with MSYS2. Windows users can now run opam init in their preferred console for a guided setup, resulting in a fully functional OCaml environment. This release represents the culmination of a multi-year effort involving extensive contributions from the community.

The OCaml ecosystem is already adapting to this new capability. A CI check for Windows compilation has been added to opam-repository, and the GitHub Action ocaml/setup-ocaml now uses opam 2.2.0, facilitating OCaml development on Windows in GitHub projects.

Community members are actively working to improve Windows compatibility across the ecosystem. Notable efforts include Hugo Heuzard's work on OCamlBuild and several other Windows-related PRs.

We encourage package authors to set up Windows CI for their projects and address Windows-related issues. This collective effort will be crucial in expanding OCaml's reach and usability on the Windows platform.

Activities:

Upgrading OCaml Package Documentation with Odoc 3.0 (W25)

Contributed by: @jonludlam (Tarides), @julow (Tarides), @panglesd (Tarides), @EmileTrotignon (Tarides), Luke Maurer (Jane Street)

Synopsis: Upgrading OCaml package documentation experience with odoc 3, featuring improved navigation, cross-package referencing, media support, and more. This upgrade aims to improve the documentation experience both locally and on OCaml.org, encouraging higher-quality package documentation.

Summary:

Following the completion and community review of the RFCs for odoc 3.0, we've made significant strides in implementing the new design and features. Our progress over the past few months has brought us close to a complete implementation of the odoc 3.0 feature set. As we finalize development and approach the first release, our focus is shifting towards integration with the rest of the ecosystem.

Key Developments in the past months include:

  • Adding new options to the odoc CLI to begin the implementation of the odoc 3 CLI
  • Implementing new syntax such as path-references
  • Developing the global sidebar with a TOC featuring standalone pages and package module hierarchy

As we near completion of the core odoc 3.0 feature set, our focus is shifting towards finalizing integration with Dune and the OCaml.org documentation pipeline. We're excited to get all of these improvements in your hands and get your feedback on the new documentation experience. Stay tuned for announcements regarding testing opportunities and the upcoming release of odoc 3.0!

Activities:

Project-Wide References in OCaml Editors (W19)

Contributed by: @vds (Tarides)

Synopsis: Introducing project-wide reference features in Merlin and OCaml LSP to enhance code navigation and refactoring capabilities, bringing OCaml's editor experience in line with other modern programming languages.

Summary:

As announced in June, Merlin project-wide references is now available in Merlin 5.1 and the preview of OCaml LSP 1.18.0. Users of LSP-powered editors (like VSCode with the OCaml Platform extension) and classic Emacs and Vim plugins can now query project-wide references of OCaml terms. This requires building the index with the new Dune alias @ocaml-index.

This release represents the culmination of a multiyear effort by the Merlin team, including extensive work on the compiler to provide the necessary information for implementing this feature in Merlin.

We're thrilled to share this feature with the community and look forward to your feedback.

While the feature should work well in most cases, we're aware of some limitations. Our next steps include adding support for interface files and module paths. Stay tuned!

Activities:

Bridging the Gap Between Merlin and OCaml LSP (W19)

Contributed by: @xvw (Tarides), @vds (Tarides)

Synopsis: Working towards feature parity between Merlin and OCaml LSP to provide a consistent, feature-rich development experience across all editors, making OCaml LSP the comprehensive backend for OCaml editor support.

Summary:

In June, we started work on bridging the gap between OCaml LSP and Merlin. We've started with exposing Merlin's type-enclosing request in OCaml LSP. The feature is now available as ocamllsp/typeEnclosing and we will work on editor integration next.

As a reminder, Merlin's type-enclosing feature allows users to get the type of the identifier under the cursor. It highlights the identifier and displays its type. Users can climb the typed-tree to display the type of larger expressions surrounding the cursor.

Since June, we’ve worked on a number of new LSP queries and code actions, including:

  • A custom ocamllsp/getDocumentation query to request the odoc documentation
  • A custom ocamllsp/construct query to browse and fill typed holes (_)
  • A code-action for syntactic and semantic movement shortcuts based on Merlin's Jump command

Activities