OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of July 30 to August 06, 2024.

Table of Contents

Ppxlib dev meetings

Continuing this thread, Patrick Ferris announced

Meeting notes are available here: https://github.com/ocaml-ppx/ppxlib/wiki/Dev-Meeting-2024-07-23

Thank you to all of the participants. If anyone is interested in adding items for the next meeting in August do ping me.

Until then happy ppx-ing :))

Pragmatic Category Theory

Dmitrii Kovanikov announced

I started writing a series on Pragmatic Category Theory for Beginners focusing on real-world use cases rather than theory. All code examples are in OCaml.

The first part was just finished:

It's just the beginning, and I have plans to describe more and provide more examples in future parts. I also plan to make a video version as well.

I hope you'll enjoy it!

ppxlib.0.33.0

Nathan Rebours announced

The Ppxlib dev team is happy to announce the release of ppxlib.0.33.0.

You can find the full changelog for this release here.

Warning silencing for [@@deriving ..] generated code

This release's main feature is a series of improvement to flags controlling unused value/module/type warnings silencing.

The ppxlib driver generates warning silencing items to prevent [@@deriving ...] generated code to trigger unused code warnings. Three warnings are disabled that way:

  • Warning 32: unused value
  • Warning 60: unused module
  • Warning 34: unused type

The first two are disabled for values and modules generated by the deriver while the third is disabled for the types in the type declaration to which the [@@deriving ...] attribute is attached.

This feature was added a long time ago to avoid manually disabling those warnings when working with derivers that generate a set of values and modules only to use a subset of those. Alternatively, the unused type warning silencing was added to allow defining an alias type only to be consumed by a deriver, e.g.:

type error = [`Not_found | `Invalid_arg] [@@deriving to_string]

We since then believe that we should not disable warnings lightly, as this behaviour makes it difficult to find and remove dead code. The right approach in those situations should be to fix the PPX derivers so that they are more configurable and can be used without triggering such warnings.

We will start to move toward removing this feature, but since it is still useful in some places, we had to come up with a plan to allow transitioning out of it.

In ppxlib.0.31.0 we added the -unused-code-warnings driver flag and the ?unused_code_warnings's Deriving.V2.make optional argument to control whether to silence Warnings 32 and 60. When both are set to true, by the user and the deriver authors, the warnings are not silenced.

As of ppxlib.0.33.0, these also control the silencing of Warning 34 (unused type). force can now be passed to the -unused-code-warnings flag in order to disable warnings silencing, regardless of the derivers opting in.

This allows users to test whether their codebase and their set of derivers rely on warning silencing or not and to use those results to eliminate dead code and/or report issues upstream to the derivers they use.

We also added a separate -unused-type-warnings flag that works similarly to -unused-code-warnings (i.e., depends on the value of the ?unused_code_warnings argument), but it only controls Warning 34 silencing, as it turns out it is less likely to cause unwanted warnings than with the other two. This will allow users to disable it more easily, without having to deal with Warnings 32 and 60 straight away.

We want to encourage users to try those on their codebase in order to see the impact it has. Did you have dead code lying around that slipped past undetected? Does this trigger unwanted warnings because of deriver's generated code?

The plan is to give the ecosystem some time to try those features and adapt by fixing individual derivers and flipping ?unused_code_warnings to true as they do. After a while, we will swap the default value of the driver flag to true so that only derivers that haven't opted in will enable warning silencing. Then as time goes we will swap the default of the Deriving.make argument so that derivers will instead have to explicitly opt out to get the warning silencing. Finally, once we are confident the ecosystem is in a good enough state, we will remove this feature altogether.

Other features

ppxlib.0.33.0 also comes with a couple of new features for PPX authors:

  • A couple new Ast_builder functions: elist_tail and plist_tail that can be used to build list expressions and patterns with a custom tail: elist_tail [expr1; expr2] tail_expr returns the expression for expr1::expr2::tail_expr.
  • Context_free.special_function', a new version of special_function that allows passing a Longident.t directly rather that relying on parsing the string argument to a Longident.t.

Finally, the release includes a few bug fixes to Longident.parse and Code_path.main_module_name and fixes the location-check flag so it is not required to also pass -check to enable location checks. It also fixes the 5.2 migrations locations, as we used to build nodes with inconsistent locations when migrating Pexp_function nodes.

Huge thanks to our external contributors

We would like to thank our external contributors who have been a huge part of this release: @octachron, @vg-b, and @jchavarri, and a special mention to @mbarbin, who has not only contributed a lot to the warning silencing features but has been extensively testing and providing very useful feedback on them.

And of course, as usual, we'd like to thank the OCaml Software Foundation who has been funding my work on Ppxlib and on this release, making all of this possible!

OCaml-LSP 1.19.0 for OCaml 5.2

vds announced

I am happy to announce, on behalf of the ocaml-lsp team, the release of ocaml-lsp-server 1.19.0 and associated libraries. This release primary goal is to bring official support for OCaml 5.2 🐫.

Features

  • Add custom [~ocamllsp/getDocumentation~](/ocaml-lsp-server/docs/ocamllsp/getDocumentation-spec.md) request (ocaml/ocaml-lsp#1336)
  • Add support for OCaml 5.2 (ocaml/ocaml-lsp#1233)

Fixes

  • Kill unnecessary ocamlformat processes with sigterm rather than sigint or sigkill (ocaml/ocaml-lsp#1343)

MlFront - A packaging system for OCaml

jbeckford announced

Here are the introductory paragraphs from its overview:

MlFront adds a Java-like packaging system to OCaml. The MlFront name is a homage to cfront which was tooling that translated "C with Classes" (now known as C++) into C code. Similarly, MlFront-based tools can translate OCaml with packages into conventional OCaml. … At its most basic core, MlFront gives a well-defined, consistent meaning to a module reference like AcmeWidgets_Std.Activities.Manufacturing across the domains of:

  1. OCaml source code.
  2. findlib libraries.
  3. opam packages.

MlFront is Apache 2.0 licensed and is meant to be used by build systems (Dune, ocamlbuild, DkCoder) and package managers (opam). One of its critical dependencies is codept.

You can read more about MlFront in the following posts (with more coming):

Cross-post notice: The first article was posted at https://lobste.rs/s/7ghslo/overview_ocamlfront; no comments (:(). But I still like to get first-hand feedback on what works well in other languages, so please chime in even if you don't feel that OCaml is your strong suit.

OCaml.org Newsletter: July 2024

Sabine Schmaltz announced

Welcome to the July 2024 edition of the OCaml.org newsletter! This update has been compiled by the OCaml.org maintainers. You can find previous updates on Discuss.

Our goal is to make OCaml.org the best resource for anyone who wants to get started and be productive in OCaml. The OCaml.org newsletter provides an update on our progress towards that goal and an overview of the changes we are working on.

We couldn't do it without all the amazing people who help us review, revise, and create better OCaml documentation and work on issues. Your participation enables us to so much more than we could just by ourselves. Thank you!

This newsletter covers:

  • Community-Driven Development of OCaml.org
  • Recipes for the OCaml Cookbook: Help us make the OCaml Cookbook really useful by contributing and reviewing recipes for common tasks!
  • Community & Marketing Pages Rework: Implementation work in progress.
  • General Improvements: As usual, we also worked on general maintenance and improvements, so we're highlighting some of the work that happened below.

Community-Driven Development of OCaml.org

After reworking most of the OCaml.org website to be more useful, more usable, and nicer to look at, the team at Tarides that has been working on OCaml.org is disbanding. However, OCaml.org will continue to be maintained and extended by by the OCaml Platform and OCaml compiler contributors, as well as by the wider OCaml community.

You can reach out to the OCaml.org maintainers to discuss any bigger changes or additions you'd like to make. Contributions to improve existing features and bug fixes are always welcome!

Recipes for the OCaml Cookbook

The OCaml Cookbook is a place where OCaml developers share how to solve common tasks using packages from the ecosystem.

A recipe is a code sample and explanations on how to perform a task using a combination of open-source libraries.

The Cookbook is live at ocaml.org/cookbook.

Here's how you can help:

  1. Help review the open pull requests for cookbook recipes!
  2. Contribute new recipes and tasks for the cookbook!

Thank you all for the many contributions! One area where we could use help is in reviewing and improving the suggested recipes and tasks.

Relevant PRs and Activities:

Community & Marketing Pages Rework

We have UI designs for the reworked and new pages of the community section, and implementation is being worked on by @oyenuga17, our former Outreachy intern!

Relevant PRs and Activities:

General Improvements and Data Additions

Summary:

  • The selected OS is now part of the anchor tag of the URL on the https://ocaml.org/install page. This allows people to link to quick install instructions for a specific OS.
  • We appreciate the contributions to the OCaml documentation!
  • We're checking for backlinks to OCaml.org again with Ahrefs.

Relevant PRs and Activities:

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.