Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of May 09 to 16, 2017.

  1. Transforming side-effects to a monad
  2. Clarity - functional programming library for OCaml
  3. PPX is harmful to our community in the long term
  4. now available
  5. Snabela 1.0: Logic-less @templates@
  6. Human-friendly Lwt: documenting and refactoring the Lwt core
  7. OCaml workshop 2017: call for presentations
  8. Ocaml Github Pull Requests
  9. Other OCaml News

Transforming side-effects to a monad


Christoph Höger said and Oleg replied:
> Assume a simple OCaml program with two primitives that can cause
> side-effects:

> let counter = ref 0
> let incr x = counter := !counter + x ; !counter
> let put n = counter := n; !counter
> put (5 + let f x = incr x in f 3)

> This example can be transformed into a pure program using a counter
> monad (using ppx_monadic syntax):

> do_;
>   i <-- let f x = incr x in f 3 ;
>   p <-- put (5 + i)
>   return p

> For a suitable definition of bind and return, both programs behave
> equivalently. My question is: How can one automatically translate a
> program of the former kind to the latter? 

More recently (Apr 29), Yaron Minsky, contrasting his view with the
moderate position by Anil Madhavapeddy, spoke very highly about

One really wonders why this obsession with monads. Why to use monadic
encoding if effects can be expressed directly? Is really

> do_;
>   i <-- let f x = incr x in f 3 ;
>   p <-- put (5 + i)
>   return p

so much better than 
        let res = put (int 5 + let f x = incr x in f 3)


One can say that the do-notation lets us use the other ways to
implement counters. Well, so does the direct notation:
        let res = put (int 5 + let f x = incr x in f 3)
This is truly OCaml code, with no PPX or other pre-processors.

It all depends on how the `primitives' int, put, incr are
defined. They can use a reference cell or pass the state or talk to a
remote computer via some RPC. If we abstract over the primitives, the
same expression can be evaluated with different models of
`counters'. Incidentally, we did not have to abstract over `let' in
this example. And we did not have to abstract over functions. Very
often our DSL can be kept to first order. Embedding into expressive
OCaml compensates. Incidentally, types really help to tell which
expression belongs to which `level' -- effectful DSL or OCaml (which
acts as a higher-order, typed `macro' language).

The recent article

presents quite a bit more challenging example, of
non-determinism. Once can write literally Curry (*) code in OCaml --
with no PPX or other preprocessors, using multiple interpretations of
non-determinism.  All works in vanilla OCaml 4.04. We don't have to
put up with functors: first-class modules really help. The modular
implicits will help even more, by putting the `implementation'
argument out of sight.

(*) Curry is a functional-logic programming language, with built-in
Yaron Minsky then said:
I like monadic encodings of concurrency because they make the places
at which interleavings can occur explicit in the types and the code.
What I've seen from more direct encodings does not have this killer
feature. I don't want to go back to the world of mutexes and

Maybe some version of algebraic effects plus appropriate tracking in
the type system will solve all the problems. But for now, I like my

Clarity - functional programming library for OCaml


Alexey Egorov announced:
I'd like to announce first release of Clarity - the library that tries to make
pure functional programming idioms as useful as possible given OCaml's absence
of higher-kinded types and typeclasses.

It features some well-known "classes" like Functor, Applicative and Monad along
with concrete instances and utility functions.

GitHub page -
Also you can install it from opam-repository.

PPX is harmful to our community in the long term


Jeremie Dimino continued this old thread:
Coming back to this thread. I had a simple idea recently for a ppx that makes it
easy to do pattern matching on abstract types. I wrote some experiments here
[1]. This essentially allows to make the AST fully abstract while still being
able to deconstruct it conveniently. In fact the patterns are even nicer than
ones matching the raw data type directly since you can build your own helper

Making the AST abstract will allow to make the API evolve in a backward
compatible way even though the underlying AST keeps changing.

I just did some experiments for now. I think we'll eventually implement this
solution properly and use it in our ppx code.

[1] now available


Anil Madhavapeddy announced:
Firstly, thank you to Marshall for kicking off this discussion. It seems clear
from the discussion that there is a desire for an asynchronous, modern
mailing-list style communications mechanism for the community. There are several
other more synchronous chat-based solutions (IRC, Slack, Gitter), but Discourse
stood out as as an open-source forum that is successfully used by other
communities such as Rust [1].

Therefore, I have set up a hosted Discourse instance at
as an experimental service, and now need your help to decide whether or not this
is a viable longer term solution for our community. It is open to signups, and
we have two immediate things to do:

- Decide how to organise the categories in the site [2]
- A timeline for shifting various services over to this [3]

Most immediately, as we decide on categories, we need volunteers to help nurture
the site and keep an eye on their areas. Globally, there are currently two
administrators (Gabriel Scherer and myself), and we can expand access controls
as the site comes into its own.

It is open to public signups immediately, so please do give it a try. Bear in
mind that as it is experimental, it is probably a good idea to expect some
rearrangements of the configuration in the next few weeks. Anyone interested is
extremely welcome to comment on the existing topics below with their opinions,
or to begin a new one as appropriate.

[1] Gabriel Scherer did the research the last time this topic came up!



Snabela 1.0: Logic-less @templates@


Malcolm Matalka announced:
Snabela 1.0 is released today (thanks to Anil for several back and

Snabela is a logic-less template system loosely based on Mustache but
attempting to fix some issues I had with Mustache.  To install Snabela
simply do:

opam install snabela

Snabela is a spec, a library, and a CLI tool to evaluate templates.

Some features Snabela has:

- It supports applying arbitrary transformers to the values being
  replaced.  This is useful for ensuring values are escaped,
  representing numeric values as money, applying locales, capitalizing
  text, etc.

- Like Mustache, it has sections for iterating over lists and
  conditionally applying a portion of a template.

- Unlike Mustache, Snabela is strict-by-default, in that a missing
  value, or the wrong type in a test is an error.

- Snabela supports escaping the template code, which is @ by doing @@.

- Snabela is meant to be implementable in a wide array of languages and
  the language is meant to be small.

You can find a gentle introduction to Snabela here:

If you run into any issues with Snabela, please don't hesitate to make
an issue here:

Human-friendly Lwt: documenting and refactoring the Lwt core


Anton Bachin announced:
Lwt is making an effort to become more reader- and contributor-friendly.

To summarize, from the PR: the core,, has been reorganized to
make it more readable. It has been equipped with thorough comments,
including a friendly overview of all concepts used by the core.

We hope this change opens Lwt up to more contributions of all kinds. It
should unblock major upcoming work, such as porting Lwt to multicore
effects. Understanding Lwt better also makes it possible to write the
much-promised new manual.

The new Lwt core is meant to be a permanent work in progress: if you
don't understand it, or find that something in it is *still* written in
a confusing way, please ask/let the Lwt maintainers know. We *want* to
help readers understand, and to improve that code! And, anyway, your
query will very likely teach *us* something.

Any review of the PR would be very helpful, to Lwt and to all of its
users – even if you read only to find typos. Also, if you have access to
a stress test, it would be very useful to put the refactored core
through the paces. There are instructions at the bottom of the PR. If
the stress test is open source, maybe we can use it as a guide for
writing a stress test specifically for Lwt, because Lwt really needs to
have at least one of those.

OCaml workshop 2017: call for presentations


Gabriel Scherer said:
This is a gentle reminder that the presentation submission deadline for the
OCaml workshop 2017 on May 31st, in two weeks. (For the details, the original
announcement at the end of this email.) Writing a talk proposal is not very
difficult (you can do it in 20-30 minutes), no need to wait for the last minute!

If you have any question about the workshop, feel free to send me an email.

If you know someone whose work would be of interest to the OCaml community,
please encourage them to propose a presentation. The workshop is a unique
(yearly) even to meet other people of the OCaml community whose work may have
been supporting your own, or building on top of it.

The programme of the ICFP conference is now available. For a sneak peek, some of
the preprints are already available
( Besides the ICFP conference, many
co-located events may also be of interest to the caml-community. See the list of
events on the ICFP webpage (ML-family languages, Haskell, Scheme, Erlang,
type-directed programming, effectful programming, high-performance computing,
art and music).

For the more theory-oriented among us, the co-located FSCD conference also have
many nice events (linear logic, unification, security, higher-dimensional
rewriting, homotopy type theory, string diagrams, proof theory, confluence,
logical frameworks, program rewriting):

Finally, if you are a student (or are a teacher with students), you should
consider sending application(s) to the Programming Language Mentoring Workshop
(, who can fund conference
attendance to university student ( the main target is undergraduate and young
graduate, corresponding to the bachelor/master cycles in Europe ). ACM also has
various forms of financial support available, in particular for students that
give a presentation; see

 Call for presentations

 OCaml 2017
 The OCaml Users and Developers Workshop

 September 8th, 2017,
 Oxford, UK,
 Co-located with ICFP 2017

 Talk proposal submission deadline: May 31st, 2017

 (Please redistribute widely.)

 The OCaml Users and Developers Workshop brings together the
 OCaml community, including users of OCaml in industry, academia,
 hobbyists and the free software community. Previous editions
 have been colocated with ICFP 2012 in Copenhagen, ICFP 2013 in
 Boston, ICFP 2014 in Gothenburg, ICFP 2015 in Vancouver and ICFP
 2016 in Nara, following the OCaml Meetings in Paris in 2010 and

 OCaml 2017 will be held on September 8th, 2017 in Oxford, UK,
 colocated with ICFP 2017 and FSCD 2017.


 Presentations and discussions will focus on the OCaml
 programming language and its community. We aim to solicit talks
 on all aspects related to improving the use or development of
 the language and its programming environment, including, for
 example (but not limited to):

 - compiler developments, new backends, runtime and architectures

 - practical type system improvements, such as (but not
 limited to) GADTs, first-class modules, generic programming,
 or dependent types

 - new library or application releases, and their design

 - tools and infrastructure services, and their enhancements

 - prominent industrial or experimental uses of OCaml, or
 deployments in unusual situations.


 It will be an informal meeting with no formal proceedings. The
 presentation material will be available online from the workshop
 homepage. The presentations may be recorded, and made available
 at a later time.

 The main presentation format is a workshop talk, traditionally
 around 20 minutes in length, plus question time, but we also
 have a poster session during the workshop -- this allows to
 present more diverse work, and gives time for discussion. The
 program committee will decide which presentations should be
 delivered as posters or talks.


 To submit a presentation, please register a description of the
 talk (about 2 pages long) at

 providing a clear statement of what will be provided by the
 presentation: the problems that are addressed, the solutions or
 methods that are proposed.

 LaTeX-produced PDFs are a common and welcome submission
 format. For accessibility purposes, we ask PDF submitters to
 also provide the sources of their submission in a textual
 format, such as .tex sources. Reviewers may read either the
 submitted PDF or the text version.

 Important dates

 Wednesday 31st May (any time zone) Abstract submission deadline
 Wednesday 28th June Author notification
 Friday 8th September 2017 OCaml Workshop

 ML family workshop and post-proceedings

 The ML family workshop, held on the previous day, deals with
 general issues of the ML-style programming and type systems,
 focuses on more research-oriented work that is less specific to
 a language in particular (OCaml). There is an overlap between
 the two workshops, and we have occasionally transferred
 presentations from one to the other in the past. The authors who
 feel their submission fits both workshops are encouraged to
 mention it at submission time and/or contact the Program Chairs.

 We are planning to publish combined post-proceedings and to
 invite interested authors of selected presentations to expand
 their abstracts for inclusion.

 Program Committee

 Ashish Agarwal, Solvuu, USA
 François Bobot, CEA, France
 Frédéric Bour, OCaml Labs, France
 Cristiano Calcagno, Facebook, UK
 Louis Gesbert, OcamlPro, France
 Sébastien Hinderer, INRIA, France
 Atsushi Igarashi, Kyoto University, Japan
 Oleg Kiselyov, Tohoku University, Japan
 Julia Lawall, INRIA/LIP6, France
 Sam Lindley, The University of Edinburgh, UK
 Louis Mandel, IBM Research, USA
 Zoe Paraskevopoulou, Princeton University, USA
 Gabriel Scherer, Northeastern University, USA

 Questions and contact

 Please send any questions to the chair:
 Gabriel Scherer

Ocaml Github Pull Requests

Gabriel Scherer and the editor compiled this list:
Here is a sneak peek at some potential future features of the Ocaml
compiler, discussed by their implementers in these Github Pull Requests.

- Make assertions nonexpansive
- move overriding class definitions to language reference chapter
- Don't use the page table when scanning closures
- updated description for printf "%g"
- document operators' associativity and precedence level

Other OCaml News

From the ocamlcore planet blog:
Here are links from many OCaml blogs aggregated at OCaml Planet,

Proving a mem/map property

New opam features: more expressive dependencies

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.

Alan Schmitt