OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of November 06 to 13, 2018.

Table of Contents

Dune 1.5.0

Rudi Grinberg announced

On behalf of the dune team, I'm pleased to announce the 1.5.0 release of dune. This release does not contain any major features, but it does contain a few notable bug fixes and a couple of useful little additions. First of all, $ dune exec now supports C-c again - I know this affected many of you. This releases introduces a couple of new aliases that will hopefully find their way into your workflows.

The first alias is @all and has been much requested by our users. Roughly speaking, $ dune build @dir/all will build all user defined targets in a the directory dir. This would include binaries, libraries, and user defined targets in dir. This alias should have been the defaulted instead of @install when running $ dune build, but we'll have to wait until dune 2.0 to make this compatibility breaking change. In the mean time, I highly recommend everyone to use $ dune build @all instead of $ dune build meanwhile. You may also set the default alias per project as well:

(alias
 (name default)
 (deps (alias_rec all)))

The second new alias is @check. It is inspired by cargo's check subcommand and roughly corresponds to type checking the project and building all artifacts necessary for editor integration - cmt, cmti's, .merlin, etc. This is the fastest target to verify that a project is in a valid state. Note that this alias will not relink binaries so it might not catch errors such as missing stubs. I find this alias handy when doing large, type driven refactoring of a codebase.

The rest of the change log is replicated below. Happy hacking!

1.5.0 (1/11/2018)

  • Filter out empty paths from OCAMLPATH and PATH (#1436, @rgrinberg)
  • Do not add the lib.cma.js target in lib's directory. Put this target in a sub directory instead. (#1435, fix #1302, @rgrinberg)
  • Install generated OCaml files with a .ml rather than a .ml-gen extension (#1425, fix #1414, @rgrinberg)
  • Allow to use the bigarray library in >= 4.07 without ocamlfind and without installing the corresponding otherlib. (#1455, @nojb)
  • Add @all alias to build all targets defined in a directory (#1409, fix #1220, @rgrinberg)
  • Add @check alias to build all targets required for type checking and tooling support. (#1447, fix #1220, @rgrinberg)
  • Produce the odoc index page with the content wrapper to make it consistent with odoc's theming (#1469, @rizo)
  • Unblock signals in processes started by dune (#1461, fixes #1451, @diml)
  • Respect OCAMLFIND_TOOLCHAIN and add a toolchain option to contexts in the workspace file. (#1449, fix #1413, @rgrinberg)
  • Fix error message when using copy_files stanza to copy files from a non sub directory with lang set to dune < 1.3 (#1486, fixes #1485, @NathanReb)
  • Install man pages in the correct subdirectory (#1483, fixes #1441, @emillon)
  • Fix version syntax check for test stanza's action field. Only emits a warning for retro-compatibility (#1474, fixes #1471, @NathanReb)
  • Fix interpretation of paths in env stanzas (#1509, fixes #1508, @diml)
  • Add context_name expansion variable (#1507, @rgrinberg)
  • Use shorter paths for generated on-demand ppx drivers. This is to help Windows builds where paths are limited in length (#1511, fixes #1497, @diml)
  • Fix interpretation of environment variables under setenv. Also forbid dynamic environment names or values (#1503, @rgrinberg).

Jerboa 0.1 (Web framework) and SandDB 0.2 (Database)

Tóth Róbert announced

Jerboa 0.1

Today I published Jerboa on opam, which is a minimalistic web framework. The main goals of the project is to make a framework, which is

  • Small and Minimalistic, so it's easy to understand
  • Flexible, so it doesn't get in your way
  • Easy to use, which means that you only need to understand the basic building blocks to use it

The framework has still a long way to go and it's not as feature rich as opium at the moment. What's missing currently that will be worked on:

  • HTTPS support
  • Nice way to serve static files
  • Security wise covering the owasp top 10 list
  • Authentication

Off Topic: Currently the framework is built on top of cohttp, but I was thinking about trying out httpaf also, but the inactive status of the project worries me.

SandDB 0.2

I published this update on SandDB one moth ago and it was mainly a fixing and refactoring release, which included:

  • Using dune instead of jbuilder
  • Switching to opam 2.0
  • Renaming a bunch of module
  • Refactoring out the implementation details into non-visible modules
  • Using Set instead of a List for filtering out non-visible records
  • Adding online documentation via github pages

For future releases I will concentrate on adding:

  • Forward and Backward streams
  • Generic database and serializer interface
  • Making the database id customizable

Links to projects:
Jerboa: https://github.com/StrykerKKD/Jerboa
SandDB: https://github.com/StrykerKKD/SandDB

Static website generators?

Perry E. Metzger asked

Are there any static site generators people particularly like that are written in OCaml?

Xavier Van de Woestyne replied

Hi ! I know :

Personnaly, I use Hakyll (in Haskell).

Armael then said

> https://github.com/Armael/stone

I wouldn't particularly recommend using it; it is quite basic, and I'm not convinced by its design anymore. It should still work though (I use it for my webpage).

Calascibetta Romain also replied

Canopy is a PoC which uses MirageOS's framework. It stills experimental and you need to pin irmin and a branch of it but it works :slight_smile: ! If you are interesting by it, we can do something to be usable by people.

Hannes Mehnert then added

I use Canopy on https://hannes.nqsb.io (with an old irmin, and some branch of Canopy). Once irmin 2.0 is released, this should be in a better shape :)

Canopy itself uses omd (https://github.com/ocaml/omd/); other generators are https://github.com/mirage/ocaml-cow/ (IIUC deprecated, but still used for mirage.io) and https://github.com/samoht/ramen

Marcus also replied

The Ray Tracer Challenge

Przemek announced

There is a nice, language-agnostic book about ray tracing called "The Ray Tracer Challenge" https://pragprog.com/book/jbtracer/the-ray-tracer-challenge I think it makes good case for learning a new language, so I share what I got so far in OCaml: https://github.com/CGenie/ray-tracer

Igarnier then saide

Hi, thanks, this is a cool idea! In case it is of interest to you, I recently published an old implementation of a toy raytracer here (in lib_test): https://github.com/igarnier/bih It uses an acceleration structure called the bounding interval hierarchy, that had its moment circa ~2007 and which could be of independent interest.

Deprecating -annot

Nicolás Ojeda Bär announced

In the last caml-devel meeting it was decided to deprecate .annot files and the -annot switch. This is currently being worked on at https://github.com/ocaml/ocaml/pull/2141.

Note this does NOT mean that .annot files will be going away anytime soon. Rather it means that technical decisions will be taken with the understanding that it is a legacy functionality and it may go away at some point in the future.

The main reason for the deprecation is that it is superseded by .cmt-based infrastructure (as exploited by e.g. merlin, ocp-index, etc).

To have a more accurate picture of the impact of the deprecation and eventual removal of this feature, we would love to hear from the community if you are still using .annot files and, if yes, whether migrating to a .cmt-based solution would present a problem.

Boris Yakobowski replied

I was thinking about the good old .annot days (finally, type information in emacs!), as well as of the not-so-good-ones (generation of the .annot file that took longer than the compilation of the file). By large, .cmt files have been a improvement in my experience.

That being said, there is one use of .annot files that I have not been able to port to .cmt files: finding (unsafe) uses of Pervasives.compare or Pervasives.equal in a codebase. My workflow is as follow:

  • generate the .annot files
  • grep for Pervasives.( = ) or Pervasives.compare with sufficient context
  • dismiss all calls that occur on a basic type (typically scalars)
  • check all remaining calls for an use on an abstract or possible-cyclic type

Clearly this process is not exactly efficient, and would be much better handled by a compiler warning – especially since the compiler would be able to notice type equalities such as t = int coming from the context. So this message must not be understood as a real suggestion to keep .annot file in the end :)

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.

Other OCaml News

From the ocamlcore planet blog

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.