OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of September 17 to 24, 2024.

Table of Contents

ocaml-trace 0.8

Simon Cruanes announced

ocaml-trace 0.8 was just released. It features a new trace collector for multiprocess programs, and a new library, trace.subscriber, for handling events in a more modular, compositional way.

For background, trace is a lightweight library that can be used to instrument your code (libraries or executable), either by hand or using ppx_trace, and offers a collector abstraction to actually collect/handle/store/write the trace events somewhere. The overhead when no collector is installed is low. There are also several collectors in trace-tef, trace-fuchsia, and (in a separate repo) tracy-client. See the github repo for more details.

qcheck-lin and qcheck-stm 0.2

Jan Midtgaard announced

I'm happy to share the 0.4 release of qcheck-lin, qcheck-stm, and qcheck-multicoretests-util: https://github.com/ocaml-multicore/multicoretests/releases/tag/0.4

The testing libraries are useful for testing your OCaml code for parallelism safety:

  • qcheck-lin offer a low effort approach, requiring little more than type signatures of the target interface (example above)
  • qcheck-stm offers stronger correctness guarantees by comparing the observed behaviour to a functional model description - under both sequential and parallel usage.

The 0.4 release brings two new "stress test" functions and also adjusts the cmd list distribution of STM_sequential:

  • #415: Remove --verbose in internal mutable_set_v5 expect test to avoid a test failure on a slow machine
  • #443: Add Lin_domain.stress_test as a lighter stress test, not requiring an interleaving search.
  • #462: Add STM_domain.stress_test_par, similar to Lin_domain.stress_test for STM models.
  • #472: Switch arb_cmds to use an exponential distribution with a mean of 10, avoiding lists of up to 10000 cmds in STM_sequential (reported by @nikolaushuber).

Happy testing! :smiley:

3rd editor tooling dev-meeting: 26th of September 🧙

vds announced

The meeting is back! We are organizing the next one on next Thursday, the 26th of September at 5pm CEST (sorry, still no timezone rotation, but we probably will for the next one). Whether you are a long time maintainer, an occasional contributor, a new comer, or simply a curious passer-by, please feel free to attend!

:sparkles: For this session, @jchavarri is going to present Melange, a toolchain that compiles ocaml/reason to javascript, and its integration in the tooling ecosystem.

:clipboard: Meeting agenda:

  • A tour-de-table to allow the participants that wish to do so to present themselves and mention issues / prs they are interested in.
  • Talk and Q&A
  • Discuss issues and pull requests that were tagged in advance or mentioned during the tour-de-table.

We’re looking forward to meeting you!

Meeting link: https://meet.google.com/nzt-owbh-yoo

Previous meeting notes are available in Merlin’s repository wiki.

First release of hachis

François Pottier announced

It is my pleasure to announce the first release of hachis, a library that offers hash sets and hash maps.

These data structures handle collisions via linear probing, a technique that relies on linear searches within an array. All of the data is stored within one large array (for hash sets) or two large arrays (for hash maps). As a result, these data structures offer good locality.

Some benchmarks suggest that hachis can consistently outperform the standard library's hash maps (Hashtbl).

To install the library, type opam update && opam install hachis.

For more details, see the documentation.

Simon Cruanes then added

The code is here for those who are curious to see how the sausage is done :-)

OCaml Platform Newsletter: June-August 2024

Thibaut Mattio announced

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+ interviews, 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 (Tarides), @Leonidas-from-XIV (Tarides), @gridbugs (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 60 developer interviews, 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

First alpha release of OCaml 5.3.0

octachron announced

Four months after the release of OCaml 5.2.0, the set of new features for the future version 5.3.0 of OCaml has been frozen. We are thus happy to announce the first alpha release for OCaml 5.3.0.

This alpha version is here to help fellow hackers join us early in our bug hunting and opam ecosystem fixing fun (see below for the installation instructions). More information about the whole release process is now available in the compiler repository.

The progresses on stabilizing the ecosystem are tracked on the opam readiness for 5.3.0 meta-issue.

The full release is expected around November, see the new prospective calendar for more information.

If you find any bugs, please report them on OCaml's issue tracker.

If you are interested in the ongoing list of new features and bug fixes, the updated change log for OCaml 5.3.0 is available on GitHub.

Installation Instructions

The base compiler can be installed as an opam switch with the following commands on opam 2.1 and later:

opam update
opam switch create 5.3.0~alpha1

The source code for the alpha is also available at these addresses:

  • Fine-Tuned Compiler Configuration

    If you want to tweak the configuration of the compiler, you can switch to the option variant with:

    opam update
    opam switch create <switch_name> ocaml-variants.5.3.0~alpha1+options <option_list>
    

    where option_list is a space separated list of ocaml-option-* packages. For instance, for a flambda and no-flat-float-array switch:

    opam switch create 5.3.0~alpha1+flambda+nffa ocaml-variants.5.3.0~alpha1+options ocaml-option-flambda ocaml-option-no-flat-float-array
    

    All available options can be listed with opam search ocaml-option.

Ascend - Dungeon RPG for your terminal

eir announced

Announcing the first release of ascend!

Venture into the depths to retrieve the stolen artifact, and hopefully escape with your life… NetHack lite.

Get it via:

opam install ascend
ascend

Rievax the Revelator is recruiting you for some "manual testing".

first release of ppx_deriving_jsonschema

Louis Roché announced

It is my pleasure to announce the first release of ppx_deriving_jsonschema. Source repo is https://github.com/ahrefs/ppx_deriving_jsonschema/

This small ppx should help you generate a (hopefully valid) json schema from an ocaml type.

Generally the derivation tries to produce a schema which looks natural, and that would also be compatible with the existing derivers for json out there. Basically you should be able to change the annotation to [@@deriving jsonschema, yojson] (or json instead of yojson) and to read/write json values that are matching the schema. There is a bit of tension on things like variants, which are represented as arrays by ppx_yojson_conv and ppx_deriving_yojson, but represented as enums by ppx_deriving_jsonschema. I plan to add a way to switch between the two behaviors soon.

type address = {
  street: string;
  city: string;
  zip: string;
} [@@deriving jsonschema]

type t = {
  name: string;
  age: int;
  email: string option;
  address: address;
} [@@deriving jsonschema]

let schema = Ppx_deriving_jsonschema_runtime.json_schema t_jsonschema

Will be turned into this schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "address": {
      "type": "object",
      "properties": {
        "zip": { "type": "string" },
        "city": { "type": "string" },
        "street": { "type": "string" }
      },
      "required": [ "zip", "city", "street" ]
    },
    "email": { "type": "string" },
    "age": { "type": "integer" },
    "name": { "type": "string" }
  },
  "required": [ "address", "age", "name" ]
}

Some more advanced functionalities are documented in the readme.

Please let me know if you see any important feature missing, if there are bugs, or if you have ideas of improvements.

This project was originally started during a Ahrefs dojo, in parallel to the ICFP conference in Milan, as a way to learn how to write a ppx. I can't recommend enough https://github.com/pedrobslisboa/ppx-by-example to get going.

opam 2.3.0~alpha1

Kate announced

As mentioned in our talk at the OCaml Workshop 2024, we decided to switch to a time-based release cycle (every 6 months), starting with opam 2.3.

As promised, we are happy to announce the first alpha release of opam 2.3.0.

What's new?

  • When loading a repository, opam now ignores files in packages' files/ directories which aren't listed in the extra-files field of the opam file. :warning: If you maintain an opam repository, please read our blog post to make sure your repository stays compatible.
  • Packages requiring an unsupported version of opam are now marked unavailable, instead of causing a repository error. This means an opam repository can now allow smoother upgrade in the future
  • opam list --latests-only: a new option to list only the latest versions of packages
  • --verbose-on: a new option to enable verbose output for specified package names.
  • opam switch import --deps-only: a new option to install only the dependencies of the root packages listed in the opam switch export file
  • opam switch list-available will now not display compilers flagged with avoid-version~/~deprecated unless --all is given, meaning that the "trunk" build of OCaml no longer appears to be the latest version
  • The builtin-0install solver was improved and should now be capable of being your default solver instead of builtin-mccs+glpk. If you wish to give it a try, simply call opam option solver=builtin-0install
  • Most of the unhelpful conflict messages were fixed :flashlight:

Various performance and 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.

Try it!

The upgrade instructions are unchanged:

For Unix systems

bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.3.0~alpha1"

or from PowerShell for Windows systems

Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/ocaml/opam/master/shell/install.ps1) } -Version 2.3.0~alpha1"

Please report any issues to the bug-tracker.

Other OCaml News

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.