OCaml Weekly News

Previous Week Up Next Week


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

Table of Contents

ReasonableCoding: a live-stream showcasing Reason/OCaml

ostera announced

For about 2 months I've been running a live-stream on Twitch called ReasonableCoding. You can pick it up live on Twitch, and subscribe to upcoming events here, but all the past episodes are available on a YouTube channel of the same name: ReasonableCoding


In the episodes, I've explored topics in software development: http servers, profiling code, async/parallel programming, unit testing, property-based testing, command line tools, esy, graphql servers, how does the OCaml garbage collector work, etc.

While it is not exclusively aimed at Reason/OCaml, they are the languages I'm using on a daily basis and thus most of the episodes feature them or libraries in the Reason/OCaml ecosystem.

What does it look like?

The format tends to be quite raw and straightforward, albeit the stream taking, normally, over 2 hours:

  1. Set up a context / state a problem
  2. Work on it live

Sometimes includes digging deep into a library, like lwt, and just making sense of the whole thing. It may include drawings.

It is quite raw in the sense that there is no language censoring, there's a lot of "how did this work?" followed up by unearthing sources and reading through documentation, and quite a few a-ha moments as well.

If you can join, there's a bunch of interaction with the audience (albeit I could improve my setup!), and users like @anmonteiro, @ulrikstrid, @p1xelHer0, @andreypopp and @thangngoc89 have made very impactful suggestions and comments, and ultimately have helped me out a lot during them.

I think you would enjoy it too :slight_smile:


Find below a list of the episodes so far (date of this edit) uploaded to YouTube.

  • Season 0
    • RC002 — Understanding Library Packaging in Sketch.sh
    • RC003 — Parallelizing the Buildgraph Execution in Cactus (Part I)
    • RC004 — Parallelizing the Buildgraph Execution in Cactus (Part II)
    • RC005 — Adding Templates to Cactus
    • RC007 — Helping Sketch.sh Packaging Libraries
    • RC008 — Async and Parallel Programming with Reason
    • RC009 — Making Command Line Tools with Cmdliner
  • Season 1
    • RC010 — Serving Static Files with http/af
    • RC011 — A Twitch.tv Command Line Interface
    • RC012 — Native GraphQL APIs
    • RC013 — Property-based Testing with qcheck
    • RC014 — Profiling Reason Native with landmarks
    • RC015 — A GraphQL Testing Server
    • RC016 — lwt from the Inside Out
    • RC017 — Reason Native with esy
    • RC018 — A GraphQL API in Erlang
    • RC019 — Building Design Systems with ReasonML (Part I)
  • Season 2
    • RC020 — Understanding the Reason Native Garbage Collector (Part I)
    • RC021 — Exploring Algebraic Effects in Eff
    • RC022 — Exploring the Actor-model in PonyLang
    • RC022 — Building Design Systems with ReasonML (Part II)

    Hope you enjoy it and feedback appreciated :smile:

Dune 1.7.0

Rudi Grinberg announced

On behalf of the dune team, I'm pleased to announce the release of dune 1.7.0. This release is the biggest release since 1.0 and I'm excited to present it to you. The change log is quite long so I'll summarize the most noteworthy changes:

  • The jbuilder binary and jbuild files are officially deprecated. But not to worry, we've created a $ dune upgrade command to do the hard work for you.
  • The virtual libraries feature has made it to 1.7.0. I've blogged about it before
  • There's now a mode to disable transitive dependencies. This mode still has some caveats because it lacks proper compiler support. But we welcome user reports regarding its usability.
  • Dune now has a --trace-file to profile slow builds using shiny flame graphs in Chrome.

As usual, the (exceedingly long) change list is available for your convenience:

1.7.0 (12/02/2010)

  • Second step of the deprecation of jbuilder: the jbuilder binary now emits a warning on every startup and both jbuilder and dune emit warnings when encountering jbuild files (#1752, @diml)
  • Change the layout of build artifacts inside _build. The new layout enables optimizations that depend on the presence of .cmx files of private modules (#1676, @bobot)
  • Fix merlin handling of private module visibility (#1653 @bobot)
  • unstable-fmt: use boxes to wrap some lists (#1608, fix #1153, @emillon, thanks to @rgrinberg)
  • skip directories when looking up programs in the PATH (#1628, fixes #1616, @diml)
  • Use lsof on macOS to implement --stats (#1636, fixes #1634, @xclerc)
  • Generate dune-package files for every package. These files are installed and read instead of META files whenever they are available (#1329, @rgrinberg)
  • Fix preprocessing for libraries with (include_subdirs ..) (#1624, fix #1626, @nojb, @rgrinberg)
  • Do not generate targets for archive that don't match the modes field. (#1632, fix #1617, @rgrinberg)
  • When executing actions, open files lazily and close them as soon as possible in order to reduce the maximum number of file descriptors opened by Dune (#1635, #1643, fixes #1633, @jonludlam, @rgrinberg, @diml)
  • Reimplement the core of Dune using a new generic memoization system (#1489, @rudihorn, @diml)
  • Replace the broken cycle detection algorithm by a state of the art one from this paper (#1489, @rudihorn)
  • Get the correct environment node for multi project workspaces (#1648, @rgrinberg)
  • Add dune compute to call internal memoized functions (#1528, @rudihorn, @diml)
  • Add --trace-file option to trace dune internals (#1639, fix #1180, @emillon)
  • Add --no-print-directory (borrowed from GNU make) to suppress Entering directory messages. (#1668, @dra27)
  • Remove --stats and track fd usage in --trace-file (#1667, @emillon)
  • Add virtual libraries feature and enable it by default (#1430 fixes #921, @rgrinberg)
  • Fix handling of Control+C in watch mode (#1678, fixes #1671, @diml)
  • Look for jsoo runtime in the same dir as the js_of_ocaml binary when the ocamlfind package is not available (#1467, @nojb)
  • Make the seq package available for OCaml >= 4.07 (#1714, @rgrinberg)
  • Add locations to error messages where a rule fails to generate targets and rules that require files outside the build/source directory. (#1708, fixes #848, @rgrinberg)
  • Let Configurator handle sizeof (in addition to negative numbers). (#1726, fixes #1723, @Chris00)
  • Fix an issue causing menhir generated parsers to fail to build in some cases. The fix is to systematically use -short-paths when calling ocamlc -i (#1743, fix #1504, @diml)
  • Never raise when printing located errors. The code that would print the location excerpts was prone to raising. (#1744, fix #1736, @rgrinberg)
  • Add a dune upgrade command for upgrading jbuilder projects to Dune (#1749, @diml)
  • When automatically creating a dune-project file, insert the detected name in it (#1749, @diml)
  • Add (implicit_transitive_deps <bool>) mode to dune projects. When this mode is turned off, transitive dependencies are not accessible. Only listed dependencies are directly accessible. (#1734, #430, @rgrinberg, @hnrgrgr)
  • Add toplevel stanza. This stanza is used to define toplevels with libraries already preloaded. (#1713, @rgrinberg)
  • Generate .merlin files that account for normal preprocessors defined using a subset of the action language. (#1768, @rgrinberg)
  • Emit (orig_src_dir <path>) metadata in dune-package for dune packages built with --store-orig-source-dir command line flag (also controlled by DUNE_STORE_ORIG_SOURCE_DIR env variable). This is later used to generate .merlin with S-directives pointed to original source locations and thus allowing merlin to see those. (#1750, @andreypopp)
  • Improve the behavior of dune promote when the files to be promoted have been deleted. (#1775, fixes #1772, @diml)
  • unstable-fmt: preserve comments (#1766, @emillon)
  • Pass flags correctly when using staged_pps (#1779, fixes #1774, @diml)
  • Fix an issue with the use of (mode promote) in the menhir stanza. It was previously causing intermediate mock files to be promoted (#1783, fixes #1781, @diml)
  • unstable-fmt: ignore files using OCaml syntax (#1784, @emillon)
  • Configurator: Add which function to replace the which command line utility in a cross platform way. (#1773, fixes #1705, @Chris00)
  • Make configurator append paths to $PKG_CONFIG_PATH on macOS. Previously it was prepending paths and thus $PKG_CONFIG_PATH set by users could have been overridden by homebrew installed libraries (#1785, @andreypopp)
  • Disallow c/cxx sources that share an object file in the same stubs archive. This means that foo.c and foo.cpp can no longer exist in the same library. (#1788, @rgrinberg)
  • Forbid use of %{targets} (or ${@} in jbuild files) inside preprocessing actions (#1812, fixes #1811, @diml)
  • Add DUNE_PROFILE environment variable to easily set the profile. (#1806, @rgrinberg)
  • Deprecate the undocumented (no_keep_locs) field. It was only necessary until virtual libraries were supported (#1822, fix #1816, @diml)
  • Rename unstable-fmt to format-dune-file and remove its --inplace option. (#1821, @emillon).
  • Autoformatting: (using fmt 1.1) will also format dune files (#1821, @emillon).
  • Autoformatting: record dependencies on .ocamlformat-ignore files (#1824, fixes #1793, @emillon)

Previous discussions on namespaces?

theindigamer asked

So far, I know of three proposals to add namespaces to OCaml

  1. Namespaces for OCaml: a proposal
  2. A Proposal for Non-Intrusive Namespaces in OCaml
  3. lpw25/namespaces

My guess is that these have been discussed in some venues (especially the papers) but didn't make the cut, and there have been other changes which help avoid the naming problem to an extent. Can someone provide links to previous discussions on these proposals?

I've looked at Github and this forum but couldn't find anything relevant. I looked at Mantis and found this ticket which is somewhat relevant but there isn't a solid discussion on any proposal per se.

To be clear, this post is not meant to stir up a discussion on whether namespaces are a good idea or not or discuss the proposals themselves.

gasche replied

"Other changes which help avoid the naming problem to an extent" are module aliases, namely the special treatment of the module Foo = Bar construct (when Bar is a module path and not something more complex), changed in 4.02 to not introduce a hard dependency on Bar – when the -no-alias-deps flag is active. This lets user manually write "namespace maps" which send short module names to longer conflict-avoiding names. Then -open Foo as a command-line argument was added to avoid having to manually open these namespace maps at the beginning of all the files of your project.

This is described in the following blog post from 2014 (before -open): Better namespaces through module aliases.

There were a lot of discussions about namespaces in 2012. I took the liberty to upload some short proposals that were made at the time by Alain Frisch, Martin Jambon, Nicolas Pouillard and Fabrice Le Fessant. At the time I wrote a synthesis (which drew laughs for being longer than the concatenation of the documents it synthesizes) which was the basis for the specification in your document 1 above (after more discussions with Nicolas Pouillard and Didier Rémy).

Yawar Amin also replied

I think another thing that took some pressure and urgency off implementing namespaces at the language level was jbuilder (and now Dune)'s built-in support for 'fake' namespaces using autogenerated module aliases. We can consider it now as the de-facto standard namespacing mechanism for OCaml.

Other OCaml News


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.