OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of December 03 to 10, 2024.

Table of Contents

Release of cppo 1.8.0

François Pottier announced

I am pleased to announce a new release of cppo (1.8.0) with one new feature and one bug fix:

  • A scope, delimited by #scope ... #endscope, limits the effect of #define, #def ... #enddef, and #undef.
  • The command cppo -version, which used to print a blank line, has been fixed.

For more details, please see the documentation.

New releases of Merlin and OCaml-LSP

vds announced

I am pleased to announce new releases of Merlin (5.3-502 and 4.18-414) and OCaml-LSP (1.20.1 and 1.20.1-4.14).

The Merlin releases bundle a handful of fixes while the LSP releases focus on adding more custom queries. These custom queries will enable tailored LSP clients to provide the same rich OCaml editing features as the one provided by the original Merlin modes for Emacs and Vim.

Latest releases of vscode-ocaml-platform already provide two new commands: Construct and Jump that respectively provide a better UI to fill typed holes with values and jump to specific parent nodes. Search by type/polarity and a command to get the type of growing and shrinking selections will also be available in the future.

c07de3130c92cb1601215531c75ecc0545a97b4d.gif

Merlin changelog

  • merlin 5.3
    • merlin binary
      • Respect the EXCLUDE_QUERY_DIR configuration directive when looking for cmt files (#1854)
      • Fix occurrences bug in which relative paths in index files are resolved against the PWD rather than the SOURCE_ROOT (#1855)
      • Fix exception in polarity search (#1858 fixes #1113)
      • Fix jump to fun targets not working (#1863, fixes #1862)
      • Fix type-enclosing results instability. This reverts some overly aggressive deduplication that should be done on the client side. (#1864)
      • Fix occurrences not working when the definition comes from a hidden source file (#1865)

OCaml-LSP changelog

  • 1.20.1
    • Features
      • Add custom [~ocamllsp/typeSearch~](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (#1369)
      • Make MerlinJump code action configurable (#1376)
      • Add custom [~ocamllsp/jump~](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (#1374)
    • Fixes
      • Fix fd leak in running external processes for preprocessing (#1349)
      • Fix prefix parsing for completion of object methods (#1363, fixes #1358)
      • Remove some duplicates in the selectionRange answers (#1368)
      • Deactivate the jump code actions by default. Clients can enable them with the merlinJumpCodeActions configuration option. Alternatively a custom request is provided for ad hoc use of the feature. (#1411)

New release of baby

François Pottier announced

It is my pleasure to announce the second release of baby.

opam update
opam install baby.20241204

baby is an OCaml library that offers persistent sets and maps based on balanced binary search trees. It offers replacements for OCaml's Set and Map modules.

Height-balanced and weight-balanced binary search trees are offered out of the box. Furthermore, to advanced users, the library offers a lightweight way of implementing other balancing strategies.

Documentation is available online.

The changes in this release are as follows:

  • The library now offers both sets and maps. The modules Baby.H.Set and Baby.W.Set continue to exist, and are compatible with OCaml's Set library. The modules Baby.H.Map and Baby.W.Map appear, and are compatible with OCaml's Map library. Furthermore, the functors Baby.H.Make and Baby.W.Make appear. These functors produce a module that contains sets, maps, and two conversion functions between sets and maps, namely domain and lift.
  • Documentation: in the signature OrderedType, clarify the specification of the function compare; this function decides a total preorder .
  • Documentation: in the preamble, clarify that, most of the time, we assume that is a total order; if an operation must be understood in the more general case where is a total preorder, then this is explicitly indicated.
  • Documentation: update the documentation of find and find_opt in accordance with the previous point.
  • A number of incompatible changes have been made; see the change log for details.

Release of Saturn 1.0

Carine Morel announced

I am thrilled to announce the release of Saturn 1.0!

Saturn is a collection of concurrent-safe data structures designed for OCaml 5. These structures have been:

  • thoroughly tested with amazing tools like STM (see this blog post) and DScheck,
  • benchmarked for performance,
  • optimized for efficiency,
  • and even verified in some cases!

If you're curious about the motivation behind Saturn and the challenges it addresses, you can read more here.

What Can You Do with Saturn?

Saturn provides a variety of data structures, including queues, stacks, hash tables, and more. All of these structures are lock-free, linearizable, and specifically designed to take full advantage of OCaml 5’s multicore capabilities.

  • Portable Data Structures

    Lock-freedom is a progress property that guarantees system-wide progress. This is a powerful and desirable feature, though it comes at the cost of some overhead. However, it offers a significant advantage: lock-free data structures avoid the need for scheduler-specific blocking mechanisms, making them compatible with any scheduler, such as Eio or Domainslib.

  • Restrictions

    Saturn’s data structures are not composable, meaning you cannot combine them (e.g., use Saturn.Queue inside Saturn.Htbl) while preserving properties like lock-freedom and linearizability.

    They are also not extensible outside of Saturn without losing these properties. For instance, Saturn.Queue does not include a length function because implementing one would introduce significant overhead (see Saturn.Bounded_queue for an example of this tradeoff). Attempting to add this functionality, such as by wrapping the queue:

    type 'a t = {size: int Atomic.t; queue : 'a Saturn.Queue.t}
    

    would result in a structure that either loses lock-freedom or is no longer linearizable.

    If you need composable lock-free data structures, consider exploring kcas_data.

Call to Action

  • Try It Out: Give Saturn a try in your projects and let us know how it works for you. If you encounter any bugs or issues, please report them on our GitHub repository.
  • Share Your Use Case: Are you already using Saturn? Let us know in the comments what you're building with it!
  • Contribute: We’d love to have more contributors. Whether it’s implementing new features, improving documentation, or suggesting enhancements, your contributions are welcome!
  • Help Shape the Future: What would you like to see in Saturn? Is there a missing data structure you need? Share your thoughts to help us build a roadmap for future development.

Thank you for your support!

Talks and Resources

If you want to learn more about Saturn, I gave a talk at the 2024 OCaml Workshop—check out the short paper and the talk.

To dive deeper into concurrent-safe data structures, I highly recommend having a look at The Art of Multiprocessor Programming, which explores the differences in design between lock-based and lock-free data structures.

Commercial Support

If you’re interested in incorporating Saturn into your commercial applications, Tarides offers professional development and support services. Feel free to contact us for more details.

Dune dev meeting

Etienne Marais announced

Hi Dune enthusiasts! :smile:

We will hold our regular Dune dev meeting on Wednesday, December, 11th at 9:00 CET. As usual, the session will be one hour long.

Whether you are a maintainer, a regular contributor, a new joiner or just curious, you are welcome to join: these discussions are opened! The goal of these meetings is to provide a place to discuss the ongoing work together and synchronise between the Dune developers ! :camel:

:calendar: Agenda

The agenda is available on the meeting dedicated page. Feel free to ask if you want to add more items in it.

:computer: Links

Dune 3.17

Etienne Marais announced

The Dune team is happy to announce the release of Dune 3.17.0! :tada:

Among the list of changes, this minor release enables the Dune cache by default for known-safe operations, adds out-of-the-box support for Wasm_of_ocaml, adds support for the~-H~ compiler flag introduced in OCaml 5.2, allows specifying code hosting services like Codeberg or GitLab organisations, and gives the possibility to run individual tests with dune runtest.

If you encounter a problem with this release, you can report it on the ocaml/dune repository.

Changelog

  • Added
    • Make Merlin/OCaml-LSP aware of "hidden" dependencies used by (implicit_transitive_deps false) via the -H compiler flag. (#10535, @voodoos)
    • Add support for the -H flag (introduced in OCaml compiler 5.2) in dune (requires lang versions 3.17). This adaptation gives the correct semantics for (implicit_transitive_deps false). (#10644, fixes #9333, ocsigen/tyxml#274, #2733, #4963, @MA0100)
    • Add support for specifying Gitlab organization repositories in source stanzas (#10766, fixes #6723, @H-ANSEN)
    • New option to control jsoo sourcemap generation in env and executable stanza (#10777, fixes #10673, @hhugo)
    • One can now control jsoo compilation_mode inside an executable stanza (#10777, fixes #10673, @hhugo)
    • Add support for specifying default values of the authors, maintainers, and license stanzas of the dune-project file via the dune config file. Default values are set using the (project_defaults) stanza (#10835, @H-ANSEN)
    • Add names to source tree events in performance traces (#10884, @jchavarri)
    • Add codeberg as an option for defining project sources in dune-project files. For example, (source (codeberg user/repo)). (#10904, @nlordell)
    • dune runtest can now run individual tests with dune runtest mytest.t (#11041, @Alizter).
    • Wasm_of_ocaml support (#11093, @vouillon)
    • Add a coqdep_flags field to the coq field of the env stanza, and to the coq.theory stanza, allowing to configure coqdep flags. (#11094, @rlepigre)
  • Fixed
    • Show the context name for errors happening in non-default contexts. (#10414, fixes #10378, @jchavarri)
    • Correctly declare dependencies of indexes so that they are rebuilt when needed. (#10623, @voodoos)
    • Don't depend on coq-stdlib being installed when expanding variables of the coq.version family (#10631, fixes #10629, @gares)
    • Error out if no files are found when using copy_files. (#10649, @jchavarri)
    • Re_export dune-section private library in the dune-site library stanza, in order to avoid failure when generating and building sites modules with implicit_transitive_deps = false. (#10650, fixes #9661, @MA0100)
    • Expect test fixes: support multiple modes and fix dependencies when there is a custom runner (#10671, @vouillon)
    • In a (library) stanza with (extra_objects) and (foreign_stubs), avoid double linking the extra object files in the final executable. (#10783, fixes #10785, @nojb)
    • Map (re_export) library dependencies to the exports field in META files, and vice-versa. This field was proposed in to https://discuss.ocaml.org/t/proposal-a-new-exports-field-in-findlib-meta-files/13947. The field is included in Dune-generated META files only when the Dune lang version is >= 3.17. (#10831, fixes #10830, @nojb)
    • Fix staged pps preprocessors on Windows (which were not working at all previously) (#10869, fixes #10867, @nojb)
    • Fix dune describe when an executable is disabled with enabled_if. (#10881, fixes #10779, @moyodiallo)
    • Fix an issue where C stubs would be rebuilt whenever the stderr of Dune was redirected. (#10883, fixes #10882, @nojb)
    • Fix the URL opened by the command dune ocaml doc. (#10897, @gridbugs)
    • Fix the file referred to in the error/warning message displayed due to the dune configuration version not supporting a particular configuration stanza in use. (#10923, @H-ANSEN)
    • Fix enabled_if when it uses env variable. (#10936, fixes #10905, @moyodiallo)
    • Fix exec -w for relative paths with –root argument (#10982, @gridbugs)
    • Do not ignore the (locks ..) field in the test and tests stanza (#11081, @rgrinberg)
    • Tolerate files without extension when generating merlin rules. (#11128, @anmonteiro)
  • Changed
    • Remove all remnants of the experimental patch-back-source-tree. (#10771, @rgrinberg)
    • Change the preset value for author and maintainer fields in the dune-project file to encourage including emails. (#10848, @punchagan)
    • Tweak the preset value for tags in the dune-project file to hint at topics not having a special meaning. (#10849, @punchagan)
    • Change some colors to improve readability in light-mode terminals (#10890, @gridbugs)
    • Forward the linkall flag to jsoo in whole program compilation as well (#10935, @hhugo)
    • Configurator uses pkgconf as pkg-config implementation when available and forwards it the target of ocamlc -config. (#10937, @pirbo)
    • Enable Dune cache by default. Add a new Dune cache setting enabled-except-user-rules, which enables the Dune cache, but excludes user-written rules from it. This is a conservative choice that can avoid breaking rules whose dependencies are not correctly specified. This is the current default. (#10944, #10710, @nojb, @ElectreAAS)
    • Do not add dune dependency in dune-project when creating projects with dune init proj. The Dune dependency is implicitely added when generating opam files (#11129, @Leonidas-from-XIV)

Spec and interface to declare dependencies in an OCaml script

jbeckford announced

This is the fourth article in the MlFront series. If you are interested in scripting frameworks that can download source code and bytecode, and inter-operate while doing so, please read:

https://diskuv.com/mlfront/overview-4/

TLDR

(Critical, verbatim snippets from article)

I have an old opam package DkSDKFFIOCaml_Std that is a low-level bridge between OCaml and other programming languages. It can be extraordinarily difficult to build, so I made it a mix of pure OCaml source code and prebuilt library downloads. Today I'll describe how embedded OCaml dependencies like the following simplifies the build process:

module _ = DkSDKFFI_OCaml
(** The bridge between OCaml and other programming languages.

    {[ `v1 [
          `sec [ `scheme "dkcoder" ];
          `blib ["https://gitlab.com/api/v4/projects/62703194/packages/generic/@DKML_TARGET_ABI@/2.1.4/@DKML_TARGET_ABI@-4.14.2-DkSDKFFI_OCaml-2.1.4-none.blib.zip"];
          `clib ["https://gitlab.com/api/v4/projects/62703194/packages/generic/@DKML_TARGET_ABI@/2.1.4/@DKML_TARGET_ABI@-4.14.2-DkSDKFFI_OCaml-2.1.4-none.clib.zip"]
        ] ]} *)

(* And use what you imported ... *)
let () =
   ignore (DkSDKFFI_OCaml.Com.create_c ())

One set of designs I created are the MlFront_Archive package formats:

  1. *.blib.zip - This is the bytecode archive. It is a zip file containing .cma, .cmi and some other critical metadata.
  2. *.clib.zip - This is the C library archive. It is a zip file containing .so or .dylib or .dll shared libraries, and also the corresponding static libraries.

The important concept is that *.blib.zip and *.clib.zip for OCaml are analogous to *.jar files for Java. The design is available at:

The remote specification design is in the MlFront_Config library:

Other OCaml News

From 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.