OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of January 12 to 19, 2021.
Table of Contents
Irmin 2.3.0
Craig Ferguson announced
I'm very happy to announce the release of the Irmin 2.3.0 family of packages, including:
irmin-pack.2.3.0
, a storage backend for Irmin designed for and used by Tezos. This release contains a host of performance improvements as well as offline CLI features such as integrity checking. It also contains a number of high-level design changes, which were discussed in a recent Tarides blog post.Finally,
irmin-pack.2.3.0
also contains a prototype of the layeredirmin-pack
store, which provides an OverlayFS-esque mode of operation forirmin-pack
in which the causal history of the store can be chunked into independently-accessable substores. This feature will eventually be deployed in a future version of Tezos.irmin-containers
, a collection of pre-defined mergeable data structures built using Irmin and compatible with any backend. These were originally provided by @kayceesrk as part ofezirmin
, and has since been modernised and upstreamed by Anirudh S.irmin-bench
, a suite of benchmarks for Irmin for use withcurrent-bench
, an experimental continuous benchmarking infrastructure for OCaml projects. Lots of work has been going on behind the scenes to make this a general benchmarking infrastructure for the Mirage ecosystem, including a recent fancy UI overhaul by new contributor @rizo.repr
, an extraction of theIrmin.Type
type representation library for use in other packages. This package contains a set of combinators for building run-time representations of types, along with various generic operations defined over those representations, including: equality, comparison, pretty-printing, JSON / binary codecs, etc. The API of this library is currently a work-in-progress, but we hope to use it more widely in the Mirage ecosystem soon.semaphore-compat
, an extraction of theSemaphore
library in OCaml 4.12, for libraries that want to maintain compatibility with earlier versions of OCaml.
The full list of changes to Irmin can be found here.
Many thanks to our open-source contributors and collaborators. Happy hacking!
Dune 2.8.0
Rudi Grinberg announced
On behalf of the dune, I'm pleased to announce the release of dune 2.8.0. This release contains many bug fixes, performance improvements, and interesting new features. I'll point out two new features that I'm most excited about.
First is the experimental dune_site
extension that makes it possible to register and load plugins at runtime. This
feature is quite involved, but we've documented it extensively in the
manual.
Another cool feature is that we've eliminated the need for .merlin files and all the caveats that came with them. Now, merlin talks to dune directly to get precise configuration for every module. Say goodbye to all those "approximate .merlin file" warnings!
I encourage everyone to upgrade as soon as possible, as earlier versions are not compatible with OCaml 4.12. Happy Hacking.
Full change log:
2.8.0 (13/01/2021)
dune rules
accepts aliases and other non-path rules (#4063, @mrmr1993)- Action
(diff reference test_result)
now acceptreference
to be absent and in that case consider that the reference is empty. Then runningdune promote
will create the reference file. (#3795, @bobot) - Ignore special files (BLK, CHR, FIFO, SOCKET), (#3570, fixes #3124, #3546, @ejgallego)
- Experimental: Simplify loading of additional files (data or code) at runtime in programs by introducing specific installation sites. In particular it allow to define plugins to be installed in these sites. (#3104, #3794, fixes #1185, @bobot)
- Move all temporary files created by dune to run actions to a single directory
and make sure that actions executed by dune also use this directory by setting
TMPDIR
(orTEMP
on Windows). (#3691, fixes #3422, @rgrinberg) - Fix bootstrap script with custom configuration. (#3757, fixes #3774, @marsam)
- Add the
executable
field toinline_tests
to customize the compilation flags of the test runner executable (#3747, fixes #3679, @lubegasimon) - Add
(enabled_if ...)
to(copy_files ...)
(#3756, @nojb) - Make sure Dune cleans up the status line before exiting (#3767, fixes #3737, @alan-j-hu)
- Add
{gitlab,bitbucket}
as options for defining project sources withsource
stanza(source (<host> user/repo))
in thedune-project
file. (#3813, @rgrinberg) - Fix generation of
META
anddune-package
files when some targets (byte, native, dynlink) are disabled. Previously, dune would generate all archives for regardless of settings. (#3829, #4041, @rgrinberg) - Do not run ocamldep to for single module executables & libraries. The dependency graph for such artifacts is trivial (#3847, @rgrinberg)
- Fix cram tests inside vendored directories not being interpreted correctly. (#3860, fixes #3843, @rgrinberg)
- Add
package
field to private libraries. This allows such libraries to be installed and to be usable by other public libraries in the same project (#3655, fixes #1017, @rgrinberg) - Fix the
%{make}
variable on Windows by only checking for agmake
binary on UNIX-like systems as a unrelatedgmake
binary might exist on Windows. (#3853, @kit-ty-kate) - Fix
$ dune install
modifying the build directory. This made the build directory unusable when$ sudo dune install
modified permissions. (fix #3857, @rgrinberg) - Fix handling of aliases given on the command line (using the
@
and@@
syntax) so as to correctly handle relative paths. (#3874, fixes #3850, @nojb) - Allow link time code generation to be used in preprocessing executable. This makes it possible to use the build info module inside the preprocessor. (#3848, fix #3848, @rgrinberg)
- Correctly call
git ls-tree
so unicode files are not quoted, this fixes problems withdune subst
in the presence of unicode files. Fixes #3219 (#3879, @ejgallego) dune subst
now accepts common command-line arguments such as--debug-backtraces
(#3878, @ejgallego)dune describe
now also includes information about executables in addition to that of libraries. (#3892, #3895, @nojb)- instrumentation backends can now receive arguments via
(instrumentation (backend <name> <args>))
. (#3906, #3932, @nojb) - Tweak auto-formatting of
dune
files to improve readability. (#3928, @nojb) - Add a switch argument to opam when context is not default. (#3951, @tmattio)
- Avoid pager when running
$ git diff
(#3912, @AltGr) - Add
(root_module ..)
field to libraries & executables. This makes it possible to use library dependencies shadowed by local modules (#3825, @rgrinberg) - Allow
(formatting ...)
field in(env ...)
stanza to set per-directory formatting specification. (#3942, @nojb) - [coq] In
coq.theory
,:standard
for theflags
field now uses the flags set inenv
profile flags (#3931 , @ejgallego @rgrinberg) - [coq] Add
-q
flag to:standard
coqc
flags , fixes #3924, (#3931 , @ejgallego) - Add support for Coq's native compute compilation mode (@ejgallego, #3210)
- Add a
SUFFIX
directive in.merlin
files for each dialect with no preprocessing, to let merlin know of additional file extensions (#3977, @vouillon) - Stop promoting
.merlin
files. Write per-stanza Merlin configurations in binary form. Add a new subcommanddune ocaml-merlin
that Merlin can use to query the configuration files. Theallow_approximate_merlin
option is now useless and deprecated. Dune now conflicts withmerlin < 3.4.0
andocaml-lsp-server < 1.3.0
(#3554, @voodoos) - Configurator: fix a bug introduced in 2.6.0 where the configurator V1 API doesn't work at all when used outside of dune. (#4046, @aalekseyev)
- Fix
libexec
andlibexec-private
variables. In cross-compilation settings, they now point to the file in the host context. (#4058, fixes #4057, @TheLortex) - When running
$ dune subst
, use project metadata as a fallback when package metadata is missing. We also generate a warning when(name ..)
is missing indune-project
files to avoid failures in production builds. - Remove support for passing
-nodynlink
for executables. It was bypassed in most cases and not correct in other cases in particular on arm32. (#4085, fixes #4069, fixes #2527, @emillon) - Generate archive rules compatible with 4.12. Dune longer attempt to generate an archive file if it's unnecessary (#3973, fixes #3766, @rgrinberg)
- Fix generated Merlin configurations when multiple preprocessors are defined for different modules in the same folder. (#4092, fixes #2596, #1212 and #3409, @voodoos)
- Add the option
use_standard_c_and_cxx_flags
todune-project
that 1. disables the unconditional use of theocamlc_cflags
andocamlc_cppflags
fromocamlc -config
in C compiler calls, these flags will be present in the:standard
set instead; and 2. enables the detection of the C compiler family and populates the:standard
set of flags with common default values when building CXX stubs. (#3875, #3802, fix #3718 and #3528, @voodoos)
lwt-canceler.0.3
Raphaël Proust announced
On behalf of Nomadic Labs, I'm happy to announce the release of Lwt-canceler version 0.3. Lwt-canceler is a small library to help programs written using Lwt to synchronise promises around resource clean-up. This library was developed as part of the Tezos codebase before being released.
With this version, the code has matured significantly (including tests, documentation and some refactoring); the next release will probably be a version 1.0 at which point a more robust versioning scheme will be used.
The documentation is available online:
https://nomadic-labs.gitlab.io/lwt-canceler/lwt-canceler/Lwt_canceler/index.html
The code is released under MIT License and hosted on Gitlab: https://gitlab.com/nomadic-labs/lwt-canceler
The new version is available on opam: opam install lwt-canceler
Happy hacking!
Interesting OCaml Articles
Weng Shiwei announced
Let me share my new blog post on understanding format6
with examples.
https://blog.tail.moe/2021/01/13/format6.html
It's almost my reading note for the paper Format Unraveled (on module Format) and experiments on utop. I tried not to be too verbose though.
Weng Shiwei later said
Well, I made a sequel of format6
post,
Understanding format6
in OCaml by diagrams
https://blog.tail.moe/2021/01/15/format6-diagram.html
This time I just use four examples with four diagrams e.g. it's the one for Scanf.sscanf
p.s. It's a pity that I missed Gabriel's post The 6 parameters of (’a, ’b, ’c, ’d, ’e, ’f) format6 after writing that one.
OCaml 4.12.0, first beta release
octachron announced
The release of OCaml 4.12.0 is close.
The set of new features has been stabilized, and core opam packages already work with this release. After three alpha releases, we have created a first beta version to help you adapt your software to the new features ahead of the release. Compared to the last alpha, this beta contains only three new bug fixes and one change to the standard library.
The base compiler can be installed as an opam switch with the following commands
opam update opam switch create 4.12.0~beta1 --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git
If you want to tweak the configuration of the compiler, you can pick configuration options with
opam update opam switch create <switch_name> --packages=ocaml-variants.4.12.0~beta1+options,<option_list> --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git
where <option_list> is a comma separated list of ocaml-option-* packages. For instance, for a flambda and afl enabled switch:
opam switch create 4.12.0~beta1+flambda+afl --packages=ocaml-variants.4.12.0~beta1+options,ocaml-option-flambda,ocaml-option-afl --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git
All available options can be listed with "opam search ocaml-option".
The source code is available at these addresses:
- https://github.com/ocaml/ocaml/archive/4.12.0-beta1.tar.gz
- https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-4.12.0~beta1.tar.gz
If you want to test this version, you may want to install the alpha opam repository
https://github.com/kit-ty-kate/opam-alpha-repository
with
opam repo add alpha git://github.com/kit-ty-kate/opam-alpha-repository.git
This alpha repository contains various packages patched with fixes in the process of being upstreamed. Once the repository installed, these patched packages will take precedence over the non-patched version.
If you find any bugs, please report them here: https://github.com/ocaml/ocaml/issues
Changes from the third alpha release
Postponed features
Additional bug fixes
- 9096, 10096: fix a 4.11.0 performance regression in classes/objects declared within a function (Gabriel Scherer, review by Leo White, report by Sacha Ayoun)
- 10106, 10112: some expected-type explanations where forgotten after some let-bindings (Gabriel Scherer, review by Thomas Refis and Florian Angeletti, report by Daniil Baturin)
- 9326, 10125: Gc.set incorrectly handles the three
custom_*
fields, causing a performance regression (report by Emilio Jesús Gallego Arias, analysis and fix by Stephen Dolan, code by Xavier Leroy, review by Hugo Heuzard and Gabriel Scherer)
OCaml for ARM MacOS
Deep in this thread, Xavier Leroy said
It's quite easy to get up to speed using the precompiled OPAM binary for macOS/ARM64.
- Download opam-2.0.7-arm64-macos.
- Move it to some directory in your PATH, rename it to
opam
, and make it executable. From a Terminal window:
mv ~/Downloads/opam-2.0.7-arm64-macos /usr/local/bin/opam chmod +x /usr/local/bin/opam
- Try to execute it:
opam init
. You will be blocked by the macOS security checks, as the binary is not signed. - Open Preferences / Security and Privacy. There should be a notice "opam was blocked because…" and an "Allow Anyway" button. Click on that button.
- Try again to execute
opam init
. You will be blocked again, but now there is an "Open" button. Click on that button.opam init
should run and install the OCaml 4.10.2 compiler. - From now on, you can run
opam
without being blocked. Use this freedom toopam install
the packages you need. - Some packages that depend on external C libraries may fail to install because these C libraries are not available. Normally we would rely on Homebrew or MacPorts to provide these C libraries, but these package collections are still being ported to macOS/ARM64.
As a reward for these minor inconveniences, you'll get excellent performance running OCaml software such as Coq. Single-core performance on a MacBook Air M1 is 20% better than the best x86 workstation I have access to.
Talk on OCaml Batteries at Houston Functional Programmers
Archive: https://discuss.ocaml.org/t/talk-on-ocaml-batteries-at-houston-functional-programmers/7103/1
Claude Jager-Rubinson announced
@UnixJunkie will be speaking (virtually, of course) on OCaml Batteries Included at Houston Functional Programmers, this coming Wednesday, Jan 20 at 7pm (U.S. Central time). His talk will cover Batteries' history, place within the OCaml ecosystem, and comparisons with OCaml's other alternative standard libraries. All are welcome to join us, even if you're not from Houston. Complete details and Zoom info are at hfpug.org.
Other OCaml News
From the ocamlcore planet blog
Here are links from many OCaml blogs aggregated at OCaml Planet.
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.