OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of August 13 to 20, 2024.

Table of Contents

MlFront - A Java-like package system for OCaml

jbeckford announced

There is now a new library MlFront_Top with a build tool mlfront-top that will generate self-contained OCaml toplevel script files with parallelism based on @c-cube's moonpool library:

.
├── AcmeWidgets_Std/
│   ├── JobsA1.ml
│   └── JobsA2.ml
└── BobBuilder_Std/
    └── JobsB.ml
$ mlfront-top -o buildscript.ml

$ ocaml buildscript.ml -j 2 -native
  legend: -> start | <- finish
     directory create: target/
     file create: target/AcmeWidgets_Std.ml
     link create: AcmeWidgets_Std/JobsA1.ml -> target/AcmeWidgets_Std__JobsA1.ml
     link create: AcmeWidgets_Std/JobsA2.ml -> target/AcmeWidgets_Std__JobsA2.ml
     link create: BobBuilder_Std/JobsB.ml -> target/BobBuilder_Std__JobsB.ml
  -> compile: AcmeWidgets_Std.JobsA1
  -> compile: AcmeWidgets_Std.JobsA2
  <- compile: AcmeWidgets_Std.JobsA1
  <- compile: AcmeWidgets_Std.JobsA2
  -> compile: AcmeWidgets_Std
  <- compile: AcmeWidgets_Std
  -> compile: BobBuilder_Std.JobsB
  <- compile: BobBuilder_Std.JobsB
  -> executable create: BobBuilder_Std.JobsB
  <- executable create: BobBuilder_Std.JobsB
  done.

$ target/BobBuilder_Std.JobsB
I am an A1!
I am an A2!
I am a B!

It requires the ocaml binary and ocamlc or ocamlopt. The complete example is at https://gitlab.com/dkml/build-tools/MlFront/-/blob/0.4.0-6/tests/MlFront_Top/jobs.t/run.t.

Rpmfile library v0.3.0 with new Eio-based reader

Mikhail announced

Today I want to tell you about new version of Rpmfile library. Rpmfile is a library for reading metadata from RPM packages. Originally Rpmfile's parser (reader) used Angstrom for parsing. And in the new release added new modern Eio-based reader.

Globally, the project is now split into four packages: rpmfile, which contains signatures and implementation-independent functions, rpmfile-unix with the original Angstrom parser, and rpmfile-eio (with rpmfile-cli) written using Eio.

My experience porting to Eio

Eio is a fantastic effect-based I/O library for a more modern age in multicore OCaml. I think it takes the best ideas from the ecosystem. So built-in Buf_read and Buf_write modules implement ideas from Angstrom and Faraday libraries. Almost API one-to-one, allowing porting via copy-paste.

But, of course, not everything is so perfect. Unlike the Angstrom.parse_ function, the Buf_read.parse function thinks I want to read a whole stream to end of input.

A snippet of the source code:

let parse ?initial_size ~max_size p flow =
  let buf = of_flow flow ?initial_size ~max_size in
  format_errors (p <* end_of_input) buf
  (*               ^^^^^^^^^^^^^^^           
                    0_0 nice (not)        *)

So I had to rewrite this function myself in a form similar to Angstrom.Consume.Prefix.

  • Is it a signed or unsigned integer?

    BE.uint16 and other similar functions are signed int even though they have the prefix u in the name for some reason.

  • And a few other differences
    • Angstrom.advance is skip
    • Angstrom.pos is consumed_bytes

P.S.

Thanks for your attention!

GitHub - meta-introspector/ocaml-libppx-import-yojson-introspector: Using libppx, ppx_import, reflect over ast using

Jim Dupont announced

Here is a working first version (with warts) of a ppxlib to yojson converter, am still testing it but the hello world is working, I have tried multiple times to get this to work, and finally settled on the import route to override the type system. code here: https://github.com/meta-introspector/ocaml-libppx-import-yojson-introspector

example snippet

{
  "pexp_desc": [
    "Pexp_constant",
    [
      "Pconst_string",
      "Hello, World!"
    ]
  ]
}

Dune Developer Preview Updates

ostera announced

Just wanted to share some of the work the Dune has been up to lately re: the Developer Preview we announced here :) – we'll be using this thread to share more updates as things go.

As always, we hold our Dune Developer meetings in public and you're more than welcome to subscribe to our public Calendar (Google, iCal)

Getting ready for the Public Beta

As we prepare for the public beta, we're ramping up the DX interviews and ensuring the first few users will have a fun, productive experience with the developer preview.

:inbox_tray: If you signed up for the Dev Preview back in May, check your inbox for a link and instructions to schedule your DX interview with us.

Here's a sample video (Mastodon or X) where you can see me building the Riot project on a machine that does not have OCaml installed. It is pretty neat!

Seriously, big shoutout to the Dune team at Tarides[0] who have been doing a phenomenal job :clap: :sparkles: :camel:

So here's what getting started with OCaml looks like today with the Dune Developer Preview as of today (August 19 2024):

  1. get dune from our binary distribution – we'll soon make this public!
  2. run dune pkg lock in your favorite project
  3. run dune build

That's it. No need to install anything else, Dune will see that lock file, fetch, and build all necessary dependencies.

:world_map: These are some strong step towards the OCaml Platform vision for 2026, that we are actively working towards. If you have any thoughts or feedback please let me know!

There are more improvements coming that will help remove friction to get started and creating a delightful experience. Both of these things we strongly believe will help onboard new users to the OCaml world.

Here's a few in the works:

  • Various DX improvements – from new outputs to simplified workflows, we want to make using Dune just delightful.
  • Bundled support for dev tools (ocalmformat, odoc, lsp) – the default toolset will be available without any extra steps! just call dune fmt, and it works. No need to manually install anything else.
  • Automatic dependency locking – when building, and even on watch mode, Dune will lock your dependencies by default and keep the lock up to date.
  • Cross-project Caching – by default we'll enabled a local Dune cache that across the system, so you never rebuild the same dependency even across projects.
  • Signed binaries with certificates of origin – we care deeply about security and want to make sure that any binary we ship will be easily verified and tracked back to its sources.

Stay tuned! :wave:

PS: here's a longer video (Mastodon, X) showing you the setup for OCaml from zero, creating a new project, and adding a dependency, all within ~5 minutes

[0] @emillon @Leonidas @gridbugs @tmattio. Ambre Shumay, Alpha Diallo, Etienne Marais

Ppxlib dev meetings

Nathan Rebours announced

This month's meeting is scheduled for tomorrow, [date=2024-08-20 time=17:00:00 timezone="Europe/London"]!

The meeting agenda thus far is to discuss the following:

The meeting will be hosted on google meet here: https://meet.google.com/yxw-ejnu-cju

Everyone is very welcome to join! :camel:

Pragmatic Category Theory: Part 2 published!

Dmitrii Kovanikov announced

I just published the second part of my series, so I updated the topic.

Let me know when notifications become too noisy :slight_smile:

Dune dev meeting on 2024-08-21, 10am CEST

Steve Sherratt announced

Hi! The next public dune dev meeting will be held on 2024-08-21, 10am CEST. Please feel free to let me know any topics you'd like us to discuss and I'll update the meeting notes. The zoom link for the meeting is: https://us06web.zoom.us/j/85096877776?pwd=cWNhU1dHQ1ZNSjZuOUZCQ0h2by9Udz09

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.