OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of April 02 to 09, 2024.

Table of Contents

moonpool 0.6

Simon Cruanes announced

Dearest friends of the dual hump,

I'm happy to announce the release of moonpool 0.6. Moonpool is a library of schedulers and concurrency primitives for OCaml 4.xx and 5.xx, based on threads (possibly spread on multiple domains). Previous release announcements (0.5, 0.4, 0.3, 0.2, 0.1) contain more details.

This release is fairly large and contains some new libraries. The biggest improvement is the addition of moonpool.fib (OCaml 5 only): it defines lightweight fibers with structured concurrency, where the fibers can run on a thread pool chosen by the user. Fibers also come with fiber-local storage and a notion of cancellation that is propagated to children fibers. Overall, fibers are a nicer abstraction than bare futures (especially with monadic combinators). There are currently no cooperative IO primitives provided by the scheduler but I have plans.

Another new, more experimental library is moonpool-lwt (OCaml 5 only) which allows for interoperability between Lwt and moonpool: a moonpool future (or fiber) can be turned into a Lwt promise; and it becomes possible to await a Lwt promise from moonpool, in a thread-safe way.

Docs:

sqids 0.1.0

Leo Soares announced

I'm happy to announce the first release (0.1.0) of the official OCaml port of Sqids.

Sqids (pronounced "squids") is an open-source library that lets you generate short unique identifiers from numbers. These IDs are URL-safe, can encode several numbers, and do not contain common profanity words.

https://opam.ocaml.org/packages/sqids

OCaml Retreat at Auroville, India (March 10th - March 15th)

Sudha Parimala announced

I'm happy to share the experience report from the first OCaml Retreat: https://ocamlretreat.org/2024/03/24/retreat-experience.html. Thanks to all the participants for contributing to the magic of the event. We hope to run more such retreats in the future!

Miou, a simple scheduler for OCaml 5

Calascibetta Romain announced

I am delighted to announce the release of miou.0.1.0. This release is undoubtedly the culmination and synthesis of the work of several individuals to offer a library that best fits our needs. We're quite convinced by the API we're proposing and quite happy with the implementation. As such, we're coming out of beta to offer version 0.1.0. Above all, this means that the API will change very little, and the library is now ready for use. However, we are not yet in 1.0.0 because we would like to give you time to use Miou, to observe possible bugs, and to give us time to correct these possible bugs in order to prepare version 1.0.0 with peace of mind. You can install the package via OPAM (it will be available soon):

$ opam install miou

We would sincerely like to thank all individuals who have contributed, whether directly or indirectly, to the project.

Furthermore, this new version of Miou builds upon the excellent work of @polytypic and his picos project. We have incorporated certain elements that are suitable for implementing a scheduler, and we hope that our efforts will lead to a certain standardization of the effects used by different schedulers in OCaml.

This rewrite has been carried out while trying to maintain the same semantics and API as what we offered in version 0.0.1~beta2 (however, it is the nature of a beta to potentially break versions). This rewrite culminated in the reimplementation of an HTTP client and server (supporting http/1.1 or h2 with TLS which can handle 200k req/sec) as well as our good old happy-eyeballs example. Moreover, the outcome of these implementations is more satisfying to us than their previous versions. At least for now, considering the various changes our cooperative has embarked on¹, we will not yet release them.

We also took the time to integrate a version of the priority queue verified using Why3. We would like to thank @Armael and @backtracking (as well as the individuals who contributed to and maintained the Vocal project) for their assistance.

Finally, I would like to personally thank the Robur cooperative for providing me with the necessary time to evolve this project.

This release further confirms what we aim to offer to users, and in this regard, we have taken the time to write a small book explaining the use of Miou. This can also be seen as an introduction to asynchronous programming and effects. It is available here and is part of the Miou distribution.

For any questions or assistance, we are available via email, this forum, or Discord.

Happy hacking!

¹: As explained in this article, we try to replace Cstruct.t by string and it requires obviously a deep change across severals packages.

OCaml.org Newsletter: March 2024

Sabine Schmaltz announced

Welcome to the March 2024 edition of the OCaml.org newsletter! This update has been compiled by the OCaml.org team. 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 OCaml community members who help us review, revise, and create better OCaml documentation. Your feedback enables us to better prioritise our work. Thank you!

This newsletter covers:

  • OCaml Cookbook: A prototype of an OCaml cookbook that provides short code examples that solve practical problems using packages from the OCaml ecosystem is on staging.ocaml.org/cookbook.
  • Dark Mode: We enabled the dark mode on all pages of OCaml.org, based on your operating system / browser settings.
  • Community & Marketing Pages Rework: We are seeking feedback on wireframes for the community section and for the marketing-related pages.
  • General Improvements: As usual, we also worked on general maintenance and improvements based on user feedback, so we're highlighting some of our work below.

Open Issues for Contributors

Upcoming OCaml Cookbook

We're in the process of adding a community-driven section to the Learn area: the OCaml Cookbook. This cookbook is designed as a collection of recipes, offering code samples for tackling real-world tasks using packages from the OCaml ecosystem. It's a practical effort to enrich our learning resources, making them more applicable and useful for our community.

This month, our focus shifted towards finalizing the cookbook for release. This includes

  • restructuring the directory structure and placement of recipe files, and
  • adding tasks to the cookbook, so that you can contribute recipes for these tasks (we took inspiration from the excellent Rust Cookbook).

It will always be possible to propose more tasks for the OCaml Cookbook. The main criteria here are:

  1. task must require more than just a single Standard Library function call to solve,
  2. task must be focused on common problems that occur when trying to build products,
  3. if in doubt, make the task more specific, instead of more generic.

A good place to give feedback on the cookbook is this discuss thread.

Relevant PRs and Activities:

Dark Mode Released

We're happy to anounce that we shipped the Dark Mode for OCaml.org. Dark mode is activated based on your operating system / browser settings. If you see anything wrong, please open an issue and include the URL on which you're seeing a problem.

Relevant PRs and Activities:

Homepage & Marketing Pages Rework

The Home page project kicked off with an analysis of user surveys and interviews, and the development of an initial wireframe for the homepage and the "Industrial Users" and "Academic Users" pages.

We've been reaching out to the community on Discuss and Twitter to find what people say about OCaml, so we can give a bit more context through testimonials on the "Academic Users" page.

Besides this, we've been asking on Twitter for ideas for the main tagline of the homepage

You can comment on the wireframes in Figma here.

If you have opinions on the homepage, feel free to share them in this discuss thread!

Community Section Rework

This week, we focused on creating wireframes for the Event, Job, Internship, and Workshop pages, followed by soliciting feedback from the community via Discuss. Concurrently, work commenced on the UI design for the Community Landing page, as well as the Event and Job pages.

We also made some improvements to the Events section on the Community page. This involves better treatment of start/end times of events, as well as listing more upcoming events.

If you have opinions on the community section, feel free to share them in this discuss thread!

Relevant PRs and Activities:

Outreachy Application Period & Internship

In March, OCaml.org hosted the application period for one Outreachy internship on creating an interactive experience for solving OCaml exercises.

The process of selecting an Outreachy intern involved creating and managing 15 issues, reviewing 61 pull requests from 8 applicants. The tasks were similar in nature and dealt with restructuring the exercises to enable an interactive experience, adding test cases and solutions (where missing).

Relevant PRs and Activities:

General Improvements and Data Additions

Relevant PRs and Activities:

Opam 102: Pinning Packages, by OCamlPro

OCamlPro announced

Greetings Cameleers,

Here’s another heads up for all opam users: Opam 102: Pinning Packages, our latest blog post breaking down opam for the community; as a keen eye would have already guessed, today's subject is package pinning!

We hope that this may be useful to anybody curious about getting acquainted with opam's pins. This article is made for whom wonders how they work and when they are useful to be aware of.

Hoping that it may serve as a reference for all newcomers to the ecosystem.

We appreciate and are thankful for every reader, we welcome all your feedback, right here, in this thread. :smile:

Kind regards, The OCamlPro Team

dune 3.15

Marek Kubica announced

We're happy to announce that Dune 3.15.0 is now available. This feature has many fixes and new features that you can find in the changelog.

There are a few new features that we would like to specially highlight.

Removal of previous limitations in many forms

Prior to Dune 3.15 there were a number of limitations where percent forms like %{env:...} could be used to expand to useful values. In this release, @rgrinberg put some effort to relax a lot of these restrictions where possible.

In the new version some of these limitations have been lifted, so for example {env:...} can be used in install stanzas (#10160).

Likewise there was no consistency where %{cma:...} or %{cmo:...} could be used. With #10169, these forms should work consistently everywhere.

Similarly the variables allowed in enabled_if fields have been expanded in #10250, from just allowing variables that can be computed from the context to now allowing all variables as long as expanding these variables does not introduce dependency cycles.

These relaxed rules can also be combined to enable a library depending on environment variables, e.g. (enabled_if %{env:ENABLE_LIBFOO=false})).

Overlapping names in different contexts

Continuing the theme of conditionally enabling or disabling code to be built, @jchavarri and @rgrinberg's work on #10220 makes it possible to have overlapping names between executable and melange.emit targets. This can be useful when a name is to be shared in different contexts (e.g. one context with native compilation and one emitting code for the browser).

Properly output UTF-8 encoded text when formatting

Dune does not assume an encoding of dune files, however when files were formatted the formatter would err on the safe side and escape bytes outside the ASCII range. This means that UTF-8 characters outside of ASCII would get escaped into decimal escape sequences.

This was especially annoying in places where the user would write natural language texts, which is common when defining Opam packages in dune-project files. For example a discussion of a paper by Paul Erdős, Peter Frankl, Vojtěch Rödl would upon reformatting be turned into Paul Erd\\197\\145s, Peter Frankl, Vojt\\196\\155 R\\195\\182, which does a disservice to these scientists and is hard to read.

Thanks to the work of @moyodiallo in #9728 starting with Dune 3.15 the original encoding will be preserved, so your package descriptions will be more readable.

Changelog

  • Added
    • Add link flags to to ocamlmklib for ctypes stubs (#8784, @frejsoya)
    • Remove some unnecessary limitations in the expansions of percent forms in install stanza. For example, the %{env:..} form can be used to select files to be installed. (#10160, @rgrinberg)
    • Allow artifact expansion percent forms (%{cma:..}, %{cmo:..}, etc.) in more contexts. Previously, they would be randomly forbidden in some fields. (#10169, @rgrinberg)
    • Allow %{inline_tests} in more contexts (#10191, @rgrinberg)
    • Remove limitations on percent forms in the (enabled_if ..) field of libraries (#10250, @rgrinberg)
    • Support dialects in dune describe pp (#10283, @emillon)
    • Allow defining executables or melange emit stanzas with the same name in the same folder under different contexts. (#10220, @rgrinberg, @jchavarri)
  • Fixed
    • coq: Delay Coq rule setup checks so OCaml-only packages can build in hybrid Coq/OCaml projects when coqc is not present. Thanks to @vzaliva for the test case and report (#9845, fixes #9818, @rgrinberg, @ejgallego)
    • Fix conditional source selection with select on bigarray in OCaml 5 (#10011, @moyodiallo)
    • melange: fix inconsistency in virtual library implementation. Concrete modules within a virtual library can now refer to its virtual modules too (#10051, fixes #7104, @anmonteiro)
    • melange: fix a bug that would cause stale import paths to be emitted when moving source files within (include_subdirs ..) (#10286, fixes #9190, @anmonteiro)
    • Dune file formatting: output utf8 if input is correctly encoded (#10113, fixes #9728, @moyodiallo)
    • Fix expanding dependencies and locks specified in the cram stanza. Previously, they would be installed in the context of the cram test, rather than the cram stanza itself (#10165, @rgrinberg)
    • Fix bug with dune exec --watch where the working directory would always be set to the project root rather than the directory where the command was run (#10262, @gridbugs)
    • Regression fix: sign executables that are promoted into the source tree (#10263, fixes #9272, @emillon)
    • Fix crash when decoding dune-package for libraries with (include_subdirs qualified) (#10269, fixes #10264, @emillon)

Changed

  • Remove the --react-to-insignificant-changes option. (#10083, @rgrinberg)

Ocsigen: summary of recent releases

Vincent Balat announced

Eliom 10.4:

  • Basic client-server distillery template: sqlite is now the default backend
  • Basic template now has license unlicense
  • Basic template fixes
  • Compatibility with Tyxml >= 4.6.0 (by Vincent Laporte)

Ocsigen Start 6.3

  • Adding license Unlicense to the template
  • Dependecy to Tyxml >= 4.6

Js_of_ocaml 5.7

Hhugo announced

Js_of_ocaml 5.7.2 was released recently. It adds missing primitives required by OCaml 5.2.0~beta

Eio Developer Meetings

Sudha Parimala announced

Following the release of Eio 1.0 (https://discuss.ocaml.org/t/ann-eio-1-0-first-major-release/14334), Eio goes into maintenance mode for a bit. We've decided to pause the Eio developer meetings until further notice. Meanwhile, we remain active on the issue tracker and the matrix channel. I encourage folks to try out Eio and report their findings.

Ocaml developer at Routine, Paris

mefyl announced

Routine (https://routine.co ) is once more looking for OCaml developers.

Routine is a personal productivity assistant and knowledge manager. The technological stack revolves heavily around OCaml which represents 80% of the codebase, both client and server side. The remaining 20% are the UIs in various frontend framework:

  • Browser and desktop (Linux/Macos/Windows) through electron, using Js_of_ocaml (eyeing on WASM).
  • iOS via Swift bindings.
  • Android via JVM bindings (upcoming).

Our technological and academic background leads us to use designs that, I think, can pique the interest of seasoned Ocaml developer. Amongst other things :

  • Type-driven programming based on ppx derivers that produces typescript declaration for frontend bindings, JSON schema to expose and consume external REST APIs (Google, Notion, …), automatic SQL bindings, etc.
  • Automatic API and foreign binding generation for the different front end technology, cross compilation.
  • Incremental based state updates to refresh minimal subsets of the app.
  • Integrated graph query language to query and manipulate all the app data, including defining custom data types and workflows.
  • Highly concurrent implementation through Lwt and Eio - migrating to the later as we go. Exception-free design. OCaml 5 with all the goodies.
  • Angstrom based parsing for the interactive console with highlighting and completion.
  • Everything is very much library-oriented, with loads of reusable and scaffolded packages. Most of the work is intended to be open sources, or already has been published.
  • An obsession for compile-time checks and type safety.

We use state of the art CI/CD and development processes. Salary is up to market standard depending on the profile, plus usual options package, to be discussed. We have a preference for presential work in our Paris 11th office (Charonne, 3 days a week) to help foster team spirit but we won't pass on talented remote individuals.

We're looking to extend the team with talented and passionate engineers who see the global picture and will work through all layers of the project to see it succeed and create something we're proud of. While we expect great OCaml and general computer science proficiency, we’re open to most levels of experience. Thoroughness and a love for well rounded, robust and beautiful software design is a must have - but that comes bundled with OCaml love, right ?

Do not hesitate to reach out for any question here, at [quentin.hocquet@routine.co](mailto:quentin.hocquet@routine.co) or refer this to someone who may be interested.

Thanks for your time and happy hacking !

dream-html 3.0.0

Yawar Amin announced

[ANN] dream-html 3.3.1

Add to_xml and pp_xml functions to render in XML style

Normally, dream-html defaults to rendering nodes in HTML style, meaning that void elements are rendered just like opening tags. Eg <br>. With the new to_xml and pp_xml functions, we can now render nodes in XML style, meaning <br />. This allows XML parsers to successfully parse the output. So eg you can use dream-html to author an ePub book.

Escape URI attributes like href with normal attribute escaping rules in addition to percent-encoding. Most significantly, ampersands are encoded now, eg /foo?a=1&b=2 is rendered as /foo?a=1&amp;b=2.

Change where line breaks are inserted into the output markup, so that there is no chance of injecting spurious whitespace into the rendered page. This gives complete control over whitespace to the user.

Other OCaml News

From the ocaml.org blog

Here are links from many OCaml blogs aggregated at the ocaml.org blog.

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.