OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of February 05 to 12, 2019.

Table of Contents

PSA: cohttp 2.0 removes old ocamlfind subpackage aliases

Anil Madhavapeddy announced

In a similar vein to the recent cstruct change, the HTTP client and server library cohttp 2.0 has just been released with some deprecation changes that you should be aware of.

In cohttp.0.99, a number of subpackages were turned into explicit opam packages to simplify dependency management. To aid migration, some compatability shims were left in place so that the old findlib names would continue to work. They have now been removed as of this release. If you were still using them, then please rename them as follows in your dune or _tags files to use the name findlib names:

  • cohttp.lwt-core -> cohttp-lwt
  • cohttp.lwt -> cohttp-lwt-unix
  • cohttp.js -> cohttp-lwt-jsoo
  • cohttp.async -> cohttp-async
  • cohttp.top -> cohttp-top

Once you have renamed it in your build system, just add the corresponding new package name to your opam dependency list as well.

The reason for removing the compatibility shim is that the old ocamlfind names do not work when embedding the dune libraries in a dune vendor workspace. So I'm removing the technical debt now to make those so-called "duniverse" deployments significantly easier to manage.

Interesting OCaml Articles

UnixJunkie announced

Ok, here is my contribution to try promoting OCaml in my field: https://jcheminf.biomedcentral.com/articles/10.1186/s13321-019-0332-0

Major Release of Base64 / Article

Calascibetta Romain wrote

Editor note: this post is too long for this newsletter. It is available online at https://tarides.com/blog/2019-02-08-release-of-base64.html

James Woodyatt then said

This is an excellent article! Thanks for writing it up.

p.s. I don't want to hijack this thread, but I'd like to mention that all three of the problems discussed in this article were already known to me when I wrote the Base64 implementation in my forthcoming Orsetto framework of structured data interchange languages. (Expect an announcement before Monday about its preview release. Also, for the MirageOS people: my implementations are generally not speed demons. I've left a lot of room for myself to make performance improvements in the future.)

Orsetto: structured data interchange languages (preview release)

James Woodyatt announced

I am pleased to announce that I've reached the preview milestone I set for my Orsetto project. As I wrote in the README file about it:

Orsetto is a standalone library comprising a core toolkit…

  • Core functional data structures and processes.
  • Unicode transport, normalization, parsing and formatting.
  • General purpose packet format encoder-decoder processes.

…used to implement streaming parsers and formatters for a useful variety of structured data interchange languages…

In the preview release, the major featured languages are only JSON and CBOR, but my hope is to expand this list to include a variety of other useful languages. The programming interfaces are sufficiently different from other implementations that I feel Orsetto may be a welcome alternative to have available.

Orsetto is currently available from my personal OPAM repository, which you can use in the conventional way:

opam repository add jhwoodyatt git+https://bitbucket.org/jhw/opam-personal.git

In two weeks, unless discussion here convinces me to delay or defer, then I will request to make Orsetto available on the public OPAM repository along with a commitment to make patch releases as necessary to correct errors.

At this time, I'm inviting the OCaml community to give it a look, post comments and questions about it here, file issues on the Issue tracker if you notice anything wrong. I'm especially interested in knowing about name conflicts that I need to avoid. Once I push to the public OPAM repository, I want to be able to move quickly toward its first stable release.

OCaml 4.08.0+beta1

Damien Doligez announced

The release of OCaml 4.08.0 is approaching. We have created a beta version to help you adapt your software to the new features ahead of the release.

The source code is available at these addresses:

https://github.com/ocaml/ocaml/archive/4.08.0+beta1.tar.gz
https://caml.inria.fr/pub/distrib/ocaml-4.08/ocaml-4.08.0+beta1.tar.gz

The compiler can also be installed as an OPAM switch with one of the following commands.

opam switch create ocaml-variants.4.08.0+beta1 --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git

or

opam switch create ocaml-variants.4.08.0+beta1+<VARIANT> --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git

where you replace <VARIANT> with one of these:

  • afl
  • default_unsafe_string
  • flambda
  • fp
  • fp+flambda

We want to know about all bugs. Please report them here: http://caml.inria.fr/mantis/bug_report_page.php

OCaml meetup in SF on 2/12

Brandon Kase announced

Hey all! We're hosting an OCaml/ReasonML meetup in SF tomorrow night (2/12) at 6:30PM. We'll have food, drinks, and some really interesting talks:

  • Shallow Dive into the Philosophy of Reprocessing by Avery Morin. How Reprocessing tries to stay approachable to enable anyone to do creative work in ReasonML.
  • A conversation about ReasonML in production (and side projects) between a junior and senior engineer

Yuki Li and Sean Grove will debate the pros/cons of using ReasonML in large production systems, whether ReasonML has a place in side projects and prototypes, and how junior developers will be helped and hurt by the language and its ecosystem.

We'll also have plenty of time to chat, eat, and hang out. People of all backgrounds / skill levels are welcome, please just RSVP below so we know how much food to get!

https://www.meetup.com/sv-ocaml/events/258482142/

Is anyone doing Design by Contract in OCaml?

Yawar Amin asked

I noticed there are a couple of research projects that implement new language features for a contract language, but not seeing anything library-based for mainline OCaml. Is anyone doing it now or in did in the past? Wondering what people's thoughts are. Personally, today I feel it should be possible to do with extension points. Maybe something like,

let divide x y = x / y
[@@dbc.pre "y <> 0"]
[@@dbc.post "result * y = x"]

Denis Ignatovich said

Check out https://try.imandra.ai. It has a bunch of examples in Jupyter notebooks. There's also the docs page https://docs.imandra.ai

Your example above would look something like this (with integer arithmetic, obv):

# let divide x y = x / y;;
val divide : Z.t -> Z.t -> Z.t = <fun>
# verify (fun (x, y) -> (y <> 0) ==> (((divide x y) * y) = x));;
- : Z.t * Z.t -> bool = <fun>
Counterexample (after 0 steps, 0.020s):
 let _x = (1, 2)
[] Conjecture refuted.
module CX : sig val _x : Z.t * Z.t end

Ivan Gotovchits also said

A possible approach, on which I was experimenting some time ago, would be to use ephemerons to attach predicates to data, which could be later checked (a mere presence check) on the caller side. Something like this:

let typecheck code =
   ensures ["well-typed"] @@
   perform_typecheck code

let normalize code =
   requires ["well-typed"];
   provides ["well-typed"; "normal-form"] @@
   perform_normalization code

let optimize code =
   requires ["normal-form"; "well-typed"];
   provides ["normal-form"; "well-typed"; "optimized"] @@
   do_optimizations code

where requires tags obj is a function of type string list -> 'a -> unit that takes a list of tags, denoting features, and checks that they are attached to the given object, and provides tags obj is a function of type string list -> object -> object takes a list of features and attaches it to the object (an alternative syntax is having type object -> unit, since an ephemeron is a mutable hashtable).

The implementation is using ephemerons, which are hashtables indexed with arbitrary boxed objects with a special treatment of liveness (i.e., values from those hashtables disappear when the index disappear, so no memory leakage should happen).

The main benefit of this approach is its simplicity, it is vanilla OCaml, it is easy to implement, and easy to disable. The main drawback is that it works only with heap values (aka boxed values) and that it is not reflected in the function signature. And of course, since it is that simple, the contract can't actually be a formula, especially that references the host language.

Dune and Multicore

james woodyatt announced

For grins, I updated my multicore OPAM switch and started looking into what is currently keeping my Orsetto project from compiling there. At the moment, the answer is that Dune doesn't compile. Which I suppose is not really noteworthy, because multicore is still way way off, but I was vastly amused by the log message that appeared on my console:

I must not segfault. Uncertainty is the mind-killer. Exceptions are the little-death that brings total obliteration. I will fully express my cases. Execution will pass over me and through me. And when it has gone past, I will unwind the stack along its path. Where the cases are handled there will be nothing. Only I will remain.

I don't know who wrote this, but it has me rolling on the floor— especially given the irony of this happening on a compiler that's trying to introduce algebraic effects. Just wanted to raise a glass for that here. Bravo, whoever you are. You have won the Internet today.

Other OCaml News

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.