OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of January 17 to 24, 2023.

Table of Contents

The Growth of the OCaml (Binary) Distribution

Fabrice Le Fessant announced

Here is a blog post that I wrote recently, about the increase of the size of the OCaml Distribution over the recent years:

https://ocamlpro.com/blog/2023_01_02_ocaml_distribution

Hope it can be interesting to read !

Ocaml 5.0.0 in Pyre - mostly smooth sailing, Gc.stat regression

Steven Troxler announced

Pyre recently switched our backend build to Ocaml 5.0.0.

It was a smooth switch for the most part. I know a lot of work went into this and we appreciate it!

We did notice one surprising regression - we had to remove a call to Gc.stat that we had for telemetry tracking.

The problem was that when we type-checked our largest Python codebase, that call was taking more than 50 seconds (in 4.14, the same call took well under 1 second).

After asking around we’ve learned that:

  • the Gc.stat implementation did change and some regression is expected
  • we should have been using Gc.quick_stat anyway, which is a change I’ll make soon

Nonetheless we thought it might be good to report this in case the slowness we experienced comes as a surprise.

Adopting the OCaml Code of Conduct

Sudha Parimala announced

Let’s use this thread to track progress of the various projects adopting this Code of Conduct. So far, it has been adopted by the following projects:

GitHub has a nice icon to indicate it -

c4ae62cab555531e63740d5a6949cc68ceda103e.gif

Esperanto, when OCaml meets Cosmopolitan

Calascibetta Romain announced

After a long time, Esperanto was upgraded with the last version of Cosmopolitan which includes threads.cmxa now. A PR on lwt (to support Esperanto) is pending but we found an issue with dune when we tried to compile a small program. This paves the way for OCaml 5 but, in the meantime, most OCaml applications can be compiled with this new toolchain (if the C files are not too fancy). A sample application is currently available here: Bob. You can also see the reproducibility of the software here (here is an article for more information).

Looking for Participants for User Survey on ocaml.org Package Documentation and Learn Area

Sabine Schmaltz announced

Here’s the promised update on what kind of feedback we got out of the user survey. I tried to distill as best as I could, there was so much feedback! :)

We have responses from 20 people in total, and a lot of those have volunteered to be interviewed by Claire. So this is excellent! In the interest of getting a good overview of the userbase, Claire will select people and send out invites.

Summary:

17 people are using OCaml for personal projects, 7 for business purposes, and 6 use OCaml for research purposes.

We have a good mix of junior and senior software development and research roles, as well as organisations of varying sizes and a broad mix of tasks people work on. I do not list these individually.

Pain points / package documentation:

  • Missing content from odoc-generated package documentation: preamble, images, guides/tutorials not visible on the navigation
  • Lack of search / indexed navigation
  • Need to be able to link to the latest version of a package to write good package documentation in READMEs
  • Problems with the rendering of documentation of modules included within another module.
  • Problems with white space, font size, layout and color, and accessibility e.g. scaling up the page gives the mobile layout
  • Documentation link on package over view page is hard to spot
  • Lack of “jump to source code”-links
  • Lack of proper dark mode
  • Lack of syntax highlighting for OCaml code in the text - authors would be more encouraged to add examples if they rendered beautifully
  • Tree view can get very busy for packages with lots of items
  • Ideas/suggestions package documentation:
    • Tree navigation should be improved, e.g. library vs toplevel module should be consolidated, hiding other libraries when going down into a module should be removed
    • Index for declarations (values, types, exceptions, etc.) of a module could be displayed in place of the empty TOC / appended to the TOC
  • Problems with content and documentation writing experience:
    • Lack of example code, quality of documentation on package docs displayed on ocaml.org
    • UI/UX of odoc for writing package documentation could be improved
    • hard to incorporate ocamldoc and markdown when writing documentation

Workarounds / package documentation:

  • inspect source code
  • odig, sherlocode.com, opam grep
  • look at package’s tests
  • search in forums, StackOverflow, look for links to package author’s documentation site in package’s public git repository

Pain points / learning section:

  • Layout/scroll problems on https://ocaml.org/doc. People need to scroll too much to see the content. Scrolling down the page does not show the tutorials and guides section, scrolling down the navbar on the left it is hard to scroll down to “common error messages”, “best practices” and “OCaml platform”
  • Accessibility problems w/visual contrast
  • Difficulty level/prerequisites of tutorials not always clear
  • Lack of important content (e.g. “single-page syntax introduction”, dune and opam guide, task-oriented examples for different levels of language learning)
  • Styling difference between manual/stdlib API and main pages
  • “Standard Library API” link goes to the index instead of to Chapter 28 of the OCaml manual (manual gives a more adequate introduction to the standard library for beginners and does not expose internal functions like the automatically generated index does)
  • Problems with outdated information
  • Pain points overall:
    • Site doesn’t motivate people enough to use OCaml by showing how OCaml is cool, interesting, nice to use and how using it makes you a better programmer
  • Ideas/suggestions learning section:
    • The more basic sections, e.g. if statements, pointers, could be merged or made collapsible to make it easier to see all items on the side navigation
    • “Papers” section is not so relevant to most OCaml beginners and should be moved below “Books”
    • Have a “beginner”/“advanced” toggle at the top of the learn page that switches the content area to be tailored better to the different use cases
    • add more context on who should read a particular book (e.g. prerequisites, topics covered)
  • Workarounds learning section:
    • directly go to the manual
    • books, blogs, other sites
    • ask on forum/discord/StackOverflow
    • check ocamlverse

    Tbh, this took a bit longer than I thought: there is so much useful info in your feedback! I want to add links to corresponding issues, but this will have to wait until I edit this post tomorrow.

OCaml Software Foundation: January 2023 update

gasche announced

A quick update on recent works of the OCaml Software Foundation. It is a non-profit foundation (earlier thread) that receives funding from our industrial sponsors each year, and tries its best to spend it to support and strengthen the OCaml ecosystem and community.

(Previous update: summer 2022.)

The funding volume we receive each year is around 200K€. (For comparison: this is the yearly cost of one experienced full-time software engineer in many parts of the world.) We do not fund people full-time for long periods. Most actions receive from 3K€ to 20K€. The work to prepare and execute actions is mostly done by the (unpaid) Executivee Committee. It is currently formed by Nicolás Ojeda Bär (’nojb’), Damien Doligez, Xavier Leroy, Kim Nguyễn, Alan Schmitt and myself, with administrative personel provided by INRIA. (Alan Schmitt is a new member this year, he agreed to work as an “interim director” from September to March to reduce my own Foundation workload a bit. Thanks Alan.)

Our current sponsors (thanks!) are ahrefs, Jane Street, Tezos, Bloomberg, Lexifi, SimCorp, MERCE and Tarides. (If your company would like to join as a sponsor, please get in touch. Unfortunately, we still cannot efficiently process small donations, so we are not calling for individual donations.)

Feel free to use this thread for questions/suggestions :-)

Recent actions

  • Outreach

    The OCaml Foundation is funding the OCaml User Meeting in Paris, which recently celebrated its 10th anniversary. We are interested in supporting OCaml meetups and events all over the world, please let us know if you are organizing something.

    We will also sponsor the 2023 edition of ICFP, the International Conference on Functional Programming. It is the academic conference that hosts the OCaml Workshop, and is attended by research and industrial users of many of our neighbor languages (Haskell, F#, Scala, Erlang, Rust, etc.).

  • Community

    We worked a few years ago on trying to build a group of OCamlers to establish a Code of Conduct (CoC) that could be adopted by interested organizations within the OCaml community, but this effort was on hold. We funded Sudha Parimala to rebuild this “code of conduct committee” and deliver a Code of Conduct that could be adopted.

    Sudha and the committee members (who are not paid by the Foundation for their work) proposed a CoC text, received a ton of (sometimes tense) feedback from the community, and iterated to get a final version that was felt acceptable by most members of the community, and is already adopted by several organizations (including this Discuss). This was a delicate, controversial effort, and it is too soon to say if has really made our community stronger yet, but we hope that it will be the case and were impressed by the work of Sudha Parimala and the committee members (currently: Louis Roché, Marcello Seri, Raja Boujbel, Simon Cruanes and Sonja Heinze).

    See the OCaml code of conduct repository for more details.

  • Ecosystem

    We are currently (partially) supporting the work of several contributors to the OCaml ecosystem, including:

    • Jonah Beckford and his Diskuv OCaml distribution for Windows,
    • Daniel Bünzli for many ongoing contributions to the OCaml ecosystem,
    • Kiran Gopinathan for Gopcaml-mode and other contributions to the ecosystem,
    • Antonio Montero’s work on Melange,
    • Zach Shipko on ocaml-rs, and
    • Petter Urkedal on Caqti.

An Emacs mode for Cram tests

Kiran Gopinathan announced

Hi all! Recently I’ve been playing with tests, and have fallen in love with dune’s cram tests :heart:

As I wasn’t able to find any support for it elsewhere, I’ve written a small Emacs mode to highlight cram tests to make it a little easier to distinguish between comments, commands and outputs:

https://gist.github.com/Gopiandcode/b17e15b09c28e70aa18453a1658021dc

Here’s what it looks like:

319945ff15cdd2c61f591a092618921fee824422.png

There’s probably some things that I’m not doing properly w.r.t to Emacs conventions, but I’ve found it works well enough for my usecases.

Aside: Cram tests really are awesome! I think they’re the best method of writing tests that I’ve found in OCaml, and I’m only saddened that I didn’t try it earlier! The ease of creating new tests (simply a new file, no boilerplate needed), updating expected outputs (dune runtest --autopromote), enabling a result to be tested (simply make sure it has a conversion to string – no need to hassle around with deriving equality etc.) are leagues above the other approaches I’ve used so far.

My current approach to testing my projects - (so far, mainly SQL-backed applications), is to first write a runner binary that calls the appropriate library functions based on its arguments and prints the result (sometimes I generate this programmatically from the types of my APIs), and then write cram tests to document the different interactions between calls that I expect. Especially when interacting with Lwt, I’ve found my cram tests to be far more readable than the corresponding unit tests that I might write with Alcotest.

Taking a look: some open OCaml Pull Requests

Lukasz Stafiniak said

Hi! Coming back to OCaml after 7+ years, today I decided to look at the open PRs to see where the language is headed. Maybe someone finds it useful. I’m mostly omitting Stdlib changes. These stood out to me:

  1. Bidirectional type checking: more type propagation during inference, improves autocompletion (e.g. for OO code).
  2. Monadic syntax for match. Also: Jane Street not using binding operators, but the old PPX ← is it still true? The let syntaxes are not fully made use of.
  3. Bigarray: free and overlap.
  4. Unwind-protect mechanism Fun.with_resource → in draft.
  5. Built-in syntax Promote constructors to functions → contested use of curried functions.
  6. Unique types to make more abstract types work well with GADTs
  7. Modular explicits, modular implicits without the implicit application part. This has the power of first-class functors, but with much more concise syntax, avoids explicit signatures, and allows local type annotations like let f {module M : S} (x : M.t) = x
  8. MetaOCaml: reserve >., syntax for .<e>., .~e, pprintast, support for .<e>., .~e.
  9. “Subtyping syntax” for modules enables things like include (M :> S).
  10. Half-precision floats in Bigarray.
  11. Atomic.modify.
  12. ~let.op x = ~ bindings parameterized by the op, complementing the current let+ x = and let* x = binding syntaxes.
  13. OCaml memory model documentation.
  14. Turn keywords to identifiers (mainly for backward compatibility).
  15. Serialize Random.State.t.
  16. Built-in syntax Promote fields to functions.

odep initial release

Simmo Saan announced

I’m glad to announce the initial release of odep – dependency graphs generator for OCaml modules, libraries and packages.

Some months ago I was frustrated with the lack of such modern tool (list of similar ones I found) and decided to code up one universal tool that covers all the use cases (xkcd reference). After interest from the community, I have now made a proper release of the tool on opam.

Example

Running odep dune | dot -Tsvg in the project’s own repository produces the following comprehensive graph. It shows modules in the project itself, clustered by dune libraries, and other findlib libraries, clustered by opam packages. This information is gathered and combined from dune describe workspace --with-deps, findlib and opam.

dune-odep.svg

See README on GitHub for more usage examples.

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