caml-list - the Caml user's mailing list
 help / Atom feed
From: Alan Schmitt <>
To: "lwn" <>, "cwn"  <>,
Subject: [Caml-list] Attn: Development Editor, Latest OCaml Weekly News
Date: Tue, 30 Nov 2021 11:51:47 +0100
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 21112 bytes --]


Here is the latest OCaml Weekly News, for the week of November 23 to 30,

Table of Contents

opam 2.1.1, opam 2.0.10, and opam-depext 1.2
OTOML 0.9.0 — a compliant and flexible TOML parsing, manipulation, and pretty-printing library
New release of Fix
New release of Menhir (20211125)
Lwt 5.5.0, Lwt_domain 0.1.0, Lwt_react.1.1.5
OCaml's CI is gradually moving to GitHub Actions
How to combine 3 monads: Async/Lwt, Error and State?

opam 2.1.1, opam 2.0.10, and opam-depext 1.2


R. Boujbel announced

  We are pleased to announce several minor releases: [opam 2.0.10],
  [opam 2.1.1], and [opam-depext 1.2].

  The opam releases consist of backported fixes, while `opam-depext' has
  been adapted to be compatible with opam 2.1, to allow for workflows
  which need to maintain compatibility with opam 2.0. With opam 2.1.1,
  if you export `OPAMCLI=2.0' into your environment then workflows
  expecting opam 2.0 should now behave even more equivalently.

  You'll find more information in the [blog post ].

[opam 2.0.10] <>

[opam 2.1.1] <>

[opam-depext 1.2]

[blog post ] <>

OTOML 0.9.0 — a compliant and flexible TOML parsing, manipulation, and pretty-printing library


Daniil Baturin announced

  A new 0.9.3 relase is available. Still not 1.0.0 just in case. The
  change I'm most glad I managed to make is that the lexer is now
  re-entrant and doesn't use any mutable state. Where can I apply for
  the "Designed for multicore OCaml" certification sticker? ;)

Breaking change in the functor interface

  I found an oversight that took a breaking change to fix. It didn't
  break any package that was already in the OPAM repository, so I'm glad
  I noticed it before it caused anyone trouble.

  My idea to make the functor take separate integer and float modules
  turned out to be misguided: it wouldn't compose with `Otoml.get_float
  ~strict:false' and similar functions that apply type conversions.

  Logically, `Otoml.get_float ~strict:false (Otoml.integer 5)' should
  produce `Otoml.TomlFloat 5.0'. However, it means that `get_float'
  needs to know how to convert integers to float. If integer and float
  types are in separate modules, that isn't possible.

  So I combined both integers and floats in a single `TomlNumber'. That
  way people who want to bring their own bignum libraries will have to
  write more code, but numbers will behave as they are expected to in a
  dynamically typed format.

  │ module BigNumber = struct
  │   type int = Z.t
  │   type float = Decimal.t
  │   let int_of_string = Z.of_string
  │   let int_to_string = Z.to_string
  │   let int_of_boolean b = if b then else
  │   let int_to_boolean n = (n <>
  │   (* Can't just reuse because their optional arguments
  │      would cause a signature mismatch. *)
  │   let float_of_string s = Decimal.of_string s
  │   (* Decimal.to_string uses "NaN" spelling
  │      while TOML requires all special float values to be lowercase. *)
  │   let float_to_string x = Decimal.to_string x |> String.lowercase_ascii
  │   let float_of_boolean b = if b then else
  │   let float_to_boolean x = (x <>
  │   let float_of_int = Decimal.of_bigint
  │   let int_of_float = Decimal.to_bigint
  │ end
  │ module Otoml = Otoml.Base.Make (BigNumber) (Otoml.Base.StringDate)

  The next release will likely be 1.0.0 for real.

New release of Fix

  Archive: <>

François Pottier announced

  I am pleased to announce a new release of Fix, with several new
  modules contribued by Frédéric Bour (thanks!).

  In short, Fix is a toolkit that helps perform memoization and fixed
  point computations (including data flow analyses). More generally, it
  offers a number of basic algorithmic building blocks that can be
  useful in many circumstances.

  │ opam update
  │ opam install fix.20211125

  Documentation can be found here:

  • <>
  • <>


  François Pottier


  • The new module `CompactQueue' offers a minimalist mutable FIFO
    queue. It is comparable with OCaml's `Queue' module. In comparison
    with `Queue', it uses a more compact internal representation:
    elements are stored contiguously in a circular array. This has a
    positive impact on performance: both time and memory consumption are
    reduced. This data structure is optimized for maximum
    throughput. (Contributed by Frédéric Bour, reviewed by François

  • The new functor `DataFlow.ForCustomMaps' offers a forward data flow
    analysis that is tuned for greater performance. (Contributed by
    Frédéric Bour, reviewed by François Pottier.)

  • The new module `Indexing' offers a safe API for manipulating indices
    into fixed-size arrays. This API involves some dynamic checks as
    well as static type checks, thereby (hopefully) greatly reducing the
    risk of confusion in code that uses many arrays and many indices
    into these arrays. (Contributed by Frédéric Bour, reviewed by
    François Pottier.)

  • In `DataFlow', allow the function `foreach_root' (which is part of
    the signature `DATA_FLOW_GRAPH') to call `contribute x _' several
    times at a single root `x'.

New release of Menhir (20211125)


François Pottier announced

  I am pleased to announce a new release of Menhir, with an exciting
  contribution by Frédéric Bour: a groundbreaking performance
  improvement in `menhir --list-errors'. This is made possible by an
  entirely new reachability algorithm, which has been designed and
  implemented by Frédéric, and which is described in our paper "Faster
  Reachability Analysis for LR(1) Parsers". This is the link to the


  To install the new release, just type

  │ opam update
  │ opam install menhir.20211125


  François Pottier

  • The command `menhir --list-errors' has been sped up by a factor of
    up to x100, and requires up to x1000 less memory, thanks to a new
    LR(1) reachability algorithm, which has been designed and
    implemented by Frédéric Bour.

  • Better document the restricted way in which the `error' token must
    be used when using `--strategy simplified'. Menhir now checks that
    this token is used only at the end of a production, and warns if
    this is not the case. (Better yet, our suggestion is to not use the
    `error' token at all!)

  • The `$syntaxerror' keyword is now forbidden when using `--strategy
    simplified'. This keyword will be entirely removed in the next
    release. Incidentally, we have just found out that it behaves
    differently under the code back-end and under the table back-end.

  • Disable OCaml warning 39 (unused rec flag) in the OCaml code
    produced by Menhir's code back-end. This does not affect the table
    back-end.  (Reported by Armaël Guéneau.)

  • Fix a bug in `--random-*' which could cause Menhir to diverge if the
    grammar uses the `error' token.

  • Warn if a terminal symbol is named `Error'. This creates a name
    clash in the public interface of the generated parser.

  • Menhir now requires OCaml 4.03.0 (instead of 4.02.3) and Dune 2.8.0
    (instead of 2.0.0).

Lwt 5.5.0, Lwt_domain 0.1.0, Lwt_react.1.1.5


Raphaël Proust announced

  It is my pleasure to announce the release of Lwt version 5.5.0,
  Lwt_domain version 0.1.0, Lwt_react version 1.1.5, Lwt_ppx version
  2.0.3 and Lwt_ppx_let version 5.5.0.


  All those packages can be installed via opam as usual.

:rotating_light:  Deprecation

  One notable change is the deprecation of `Lwt_main.yield' and
  `Lwt_unix.yield'. It is recommended to use `Lwt.pause' instead.

:rocket:  Lwt_domain: an interface to multicore parallelism

  Another notable change is the addition of the Lwt_domain package. This
  package includes a single module `Lwt_domain' with functions to
  execute some computations in parallel, using the features of Multicore
  OCaml. The package requires an OCaml compiler with domains support to

  Code for this package is the work of @sudha with reviews and packaging
  from Lwt contributors.

Other changes

  The full list of changes is available in the [CHANGES file].

[CHANGES file] <>

OCaml's CI is gradually moving to GitHub Actions


Sora Morimoto announced

  The OCaml team started switching to GitHub Actions last year for some
  of the official OCaml repositories. Also, we have released some CI
  related stuff, such as setup-ocaml, to the community. Some OCaml
  hackers also know that CI in the OCaml community is gradually
  switching to GitHub Actions nowadays.

  However, what gradually became a problem when we started switching was
  that the number of concurrent jobs that could run in a free account on
  GitHub was not enough for our activeness.

  One of the major pain points for compiler contributors is that the
  wait time for CI to complete, which is unrelated to the actual build,
  is too long. However, this has been a pain point in all services, even
  before GitHub Actions.

  The GitHub team did their best to help us make it better. As a result,
  they offered to upgrade the OCaml organization's plan to the team plan
  for free, which means that we can now benefit from a range of
  features, including access to 3x more concurrent runners than before.

  • About team plan:
  • Concurrency/plan:

  We would like to thank GitHub for supporting our team and Ahmed Bilal,
  who supported this effort.

How to combine 3 monads: Async/Lwt, Error and State?


Deep in this thread, Ivan Gotovchits said

  The monads library provides the transformers for some well-known
  monads. All these monads have a more or less standard implementation,
  offering the same performance as any other monadic library can
  offer. Like there is no better way of implementing the state monad
  other than a function. We have experimented a lot with different
  performance optimizations, such as boxing and unboxing it and inlining
  various operators, and keep experimenting to get the maximum from the
  current compiler. In BAP, we heavily use the monads library, first of
  all for our [knowledge representation and reasoning engine], which is
  the foundation for all BAP analyses. We also use it for [emulating
  binary programs].  The rich interface is here to make our life easier
  and more comfortable when we use monads. It definitely comes for free¹
  as the number of functions doesn't affect the performance of the
  underlying monad.

  But… there is always a but :) Stacking monads using a transformer does
  have a price. Even with the flambda compiler. The latter is doing an
  excellent job of unstacking them and eliminating the overhead of
  having a chain of monads. But our latest experiments show that a
  custom-made monad (still with the monads library) performs better
  under either branch of the compiler. We [have rewritten our main
  monads] that were relying on transformers and got from 20% to 50%
  performance improvement. But that is not to say that the monads
  library itself is slow or that we're not using it, it is to say that
  there are other options to transformers that might work in some cases.
  See the linked PR if you want to learn the trick.

  ¹⁾ Provided that we ignore the size of the executable, e.g., linking
  the core_kernel library results in a quite large binary, which may
  increase the startup time. Insignificantly, but in some use cases, it
  might be a significant factor.

[knowledge representation and reasoning engine]

[emulating binary programs]

[have rewritten our main monads]

Ivan Gotovchits then said

  As it was already suggested, you can use [monad transformers], to
  compose several monads into a single monad. As a show-case, we will
  use the [monads] library (disclaimer, I am an author of this library),
  which you can install with

  │ opam install monads

  It offers most of the well-known monads in a form of a monad
  transformer, which in terms of OCaml, is a functor that takes a monad
  and returns a new monad that enriches it with some new behavior. For
  example, to make a non-deterministic error monad, we can do
  `Monad.List.Make(Monad.Result.Error)' and get a monadic structure
  (i.e., a module that implements the [Monad.S] interface) that is both
  a list monad and an error monad.  The small caveat is that the
  operations of the wrapped monad, the error monad in our case, are not
  available directly, so we have to _lift_ them, e.g.,
  │ let fail p = lift @@ p
  So that in the end, the full implementation of the transformed monad
  still requires some boilerplate code,

  │ module ListE = struct
  │   type 'a t = 'a list Monad.Result.Error.t
  │   include Monad.List.Make(Monad.Result.Error)
  │   let fail p = p
  │   (* and so on for each operation that is specific to the wrapped monad *)
  │ end

  Now, let's try wrapping the Lwt monad into the state. We don't want to
  add the Error monad because Lwt is already the error monad and adding
  an extra layer of errors monad is not what we want. First of all, we
  need to adapt the `Lwt' monad to the `Monad.S' interface, e.g.,
  │ module LwtM = struct
  │   type 'a t = 'a Lwt.t
  │   include Monad.Make(struct
  │       type 'a t = 'a Lwt.t
  │       let return = Lwt.return
  │       let bind = Lwt.bind
  │       let map x ~f = f x
  │       let map = `Custom map
  │     end)
  │ end

  If we want to keep the state type monomorphic, then we will need a
  module for it. Suppose your state is represented as,
  │ module State = struct
  │   type t = string Map.M(String).t
  │ end

  Now, we can use it to build our `State(Lwt)' Russian doll,
  │ module IO = struct
  │   include Monad.State.T1(State)(LwtM)
  │   include Monad.State.Make(State)(LwtM)
  │   (* let's lift [read] as an example *)
  │   let read fd buf ofs len =
  │     lift ( fd buf ofs len)
  │ end

  The `Monad.State.T1' functor is used to create the types for the
  generated monad. You can write them manually, of course, like as we
  did in the List(Error) example, but the type generating modules are
  here for the convenience¹

  Now, let's get back to the problem of the lifting. It looks tedious to
  impossible to lift every operation from Lwt.  Commonly, we try to put
  the smaller monad inside, to minimize the work, but it doesn't work
  with Lwt as the latter is not a transformer. So what is the solution?
  For me, the solution is to not lift the operations at all, but
  instead, define your IO abstraction and hide that it is using Lwt
  underneath the hood. This will make the code that uses this new
  abstraction more generic and less error-prone so that it can focus on
  the business logic and the implementation details could be hidden
  inside the monad implementation. This is what the monads are for,

  ¹⁾ We omit the types from the output of the `Make' functor since for a
  long time OCaml didn't allow the repetition of types in a structure so
  having the types in it will prevent us from composing various flavors
  of monads using `include'. It is also a long-time convention widely
  used in many OCaml libraries, including Core and Async. A convention
  that we probably don't need anymore.

[monad transformers] <>




  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

  If you also wish to receive it every week by mail, you may subscribe

  [Alan Schmitt]

[send me a message] <>

[the archive] <>

[RSS feed of the archives] <>

[online] <>

[Alan Schmitt] <>

[-- Attachment #2: Type: text/html, Size: 39307 bytes --]

         reply index

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03  7:35 Alan Schmitt
2019-10-15  7:28 Alan Schmitt
2019-11-05  6:55 Alan Schmitt
2019-11-12 13:21 Alan Schmitt
2019-11-26  8:33 Alan Schmitt
2019-12-03 15:43 Alan Schmitt
2019-12-10  8:21 Alan Schmitt
2019-12-17  8:52 Alan Schmitt
2019-12-31  9:18 Alan Schmitt
2020-01-07 13:43 Alan Schmitt
2020-01-14 14:17 Alan Schmitt
2020-01-21 14:09 Alan Schmitt
2020-01-28 10:54 Alan Schmitt
2020-02-04  8:47 Alan Schmitt
2020-02-18  8:18 Alan Schmitt
2020-02-25  8:51 Alan Schmitt
2020-03-03  8:00 Alan Schmitt
2020-03-10 14:29 Alan Schmitt
2020-03-17 11:04 Alan Schmitt
2020-03-24  9:31 Alan Schmitt
2020-03-31  9:55 Alan Schmitt
2020-04-07  7:51 Alan Schmitt
2020-04-14  7:28 Alan Schmitt
2020-04-21  8:58 Alan Schmitt
2020-04-28 12:45 Alan Schmitt
2020-05-05  7:45 Alan Schmitt
2020-05-12  7:46 Alan Schmitt
2020-05-19  9:53 Alan Schmitt
2020-06-09  8:29 Alan Schmitt
2020-06-16  8:36 Alan Schmitt
2020-06-30  7:00 Alan Schmitt
2020-07-07 10:05 Alan Schmitt
2020-07-14  9:55 Alan Schmitt
2020-07-21 14:43 Alan Schmitt
2020-07-28 16:58 Alan Schmitt
2020-08-18  7:26 Alan Schmitt
2020-09-01  7:55 Alan Schmitt
2020-09-08 13:11 Alan Schmitt
2020-09-22  7:27 Alan Schmitt
2020-09-29  7:02 Alan Schmitt
2020-10-06  7:22 Alan Schmitt
2020-10-20  8:16 Alan Schmitt
2020-10-27  8:44 Alan Schmitt
2020-11-03 15:16 Alan Schmitt
2020-12-01  8:55 Alan Schmitt
2020-12-15  9:51 Alan Schmitt
2020-12-22  8:49 Alan Schmitt
2020-12-29 10:00 Alan Schmitt
2021-01-05 11:22 Alan Schmitt
2021-01-12  9:47 Alan Schmitt
2021-01-19 14:28 Alan Schmitt
2021-01-26 13:25 Alan Schmitt
2021-02-02 13:56 Alan Schmitt
2021-02-16 13:53 Alan Schmitt
2021-02-23  9:52 Alan Schmitt
2021-03-09 10:59 Alan Schmitt
2021-03-16 10:32 Alan Schmitt
2021-03-23  9:05 Alan Schmitt
2021-03-30 14:56 Alan Schmitt
2021-04-06  9:42 Alan Schmitt
2021-04-20  9:07 Alan Schmitt
2021-04-27 14:26 Alan Schmitt
2021-05-04  8:58 Alan Schmitt
2021-05-11 14:48 Alan Schmitt
2021-05-25  7:30 Alan Schmitt
2021-06-01  9:23 Alan Schmitt
2021-06-22  9:05 Alan Schmitt
2021-06-29 12:24 Alan Schmitt
2021-07-06 12:34 Alan Schmitt
2021-07-20 12:59 Alan Schmitt
2021-07-27  8:54 Alan Schmitt
2021-08-10 16:47 Alan Schmitt
2021-08-17  6:24 Alan Schmitt
2021-08-24 13:44 Alan Schmitt
2021-09-07 13:24 Alan Schmitt
2021-09-21  9:10 Alan Schmitt
2021-09-28  6:37 Alan Schmitt
2021-10-19  8:23 Alan Schmitt
2021-11-02  8:50 Alan Schmitt
2021-11-09 10:08 Alan Schmitt
2021-11-16  8:41 Alan Schmitt
2021-11-30 10:52 Alan Schmitt [this message]
2021-12-14 11:02 Alan Schmitt
2021-12-21  9:12 Alan Schmitt
2021-12-28  9:00 Alan Schmitt
2022-01-04  7:56 Alan Schmitt
2022-01-11  8:21 Alan Schmitt
2022-01-25 12:45 Alan Schmitt
2022-02-01 13:07 Alan Schmitt
2022-02-08 13:16 Alan Schmitt
2022-02-22 12:43 Alan Schmitt
2022-03-01 13:54 Alan Schmitt
2022-03-15  9:59 Alan Schmitt
2022-03-22 13:01 Alan Schmitt
2022-03-29  7:43 Alan Schmitt
2022-04-05 11:50 Alan Schmitt
2022-04-12  8:10 Alan Schmitt
2022-04-19  5:35 Alan Schmitt
2022-04-26  6:44 Alan Schmitt
2022-05-03  9:11 Alan Schmitt
2022-05-10 12:31 Alan Schmitt
2022-05-17  7:12 Alan Schmitt
2022-05-24  8:04 Alan Schmitt

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror

AGPL code for this site: git clone public-inbox