Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of April 28 to May 05, 2015.

  1. js_of_ocaml with node
  2. OCaml art exhibition in Venice
  3. Albatross 0.1
  4. Safe UTF-8 string literals and pattern matching for OCaml
  5. will expire in 60 days
  6. Other OCaml News

js_of_ocaml with node


Continuing the thread from last week, Mauricio Fernández said:
I've got some bindings for nodejs stuff including FS operations, sockets,
events, processes, etc.; will try to publish it tomorrow. Note that some
nodejs functions require variadic callbacks as supported by the patches
available at

The hand-written bindings look like this (just a sneak peek):


    let require x =
      let require = Js.Unsafe.eval_string "require" in
        require##call(require, Js.string x)

    (* vim: set ft=ocaml: *)


    open Printf
    open Lwt

    class type error =
      method message : Js.js_string Js.t Js.prop

    type maybe_error = error Js.t Js.opt

    class type stats =
      method dev     : int Js.readonly_prop
      method ino     : int Js.readonly_prop
      method mode    : int Js.readonly_prop
      method nlink   : int Js.readonly_prop
      method uid     : int Js.readonly_prop
      method gid     : int Js.readonly_prop
      method rdev    : int Js.readonly_prop
      method size    : float Js.t Js.readonly_prop
      method blksize : int Js.readonly_prop
      method blocks  : int Js.readonly_prop
      method atime   : Js.t Js.readonly_prop
      method mtime   : Js.t Js.readonly_prop
      method ctime   : Js.t Js.readonly_prop

    and watch_options =
      method persistent : bool Js.t Js.prop

    class type fs =
      method existsSync : Js.js_string Js.t -> bool Js.t Js.meth
      method exists : Js.js_string Js.t -> (bool Js.t -> unit) Js.callback -> unit Js.meth

      method readFile :
        Js.js_string Js.t ->
        (maybe_error -> Node_net.buffer Js.t -> unit) Js.callback -> unit Js.meth

      method readFileSync : Js.js_string Js.t -> Node_net.buffer Js.t Js.meth

      method readdirSync : Js.js_string Js.t -> Js.js_string Js.t Js.js_array Js.t Js.meth

      method statSync : Js.js_string Js.t -> stats Js.t Js.opt Js.meth
      method lstatSync : Js.js_string Js.t -> stats Js.t Js.opt Js.meth

      method mkdir :
        Js.js_string Js.t -> int -> (maybe_error -> unit) Js.callback -> unit Js.meth
      method mkdirSync : Js.js_string Js.t -> int -> unit Js.meth

      method unlink : Js.js_string Js.t -> (maybe_error -> unit) Js.callback -> unit Js.meth
      method unlinkSync : Js.js_string Js.t -> unit Js.meth

      method watch : 'a. Js.js_string Js.t -> (#watch_options as 'a) Js.t ->
                     (Js.js_string -> Js.js_string -> unit) Js.callback -> unit Js.meth

    let fs : fs Js.t = Node_require.require "fs"

    let err_callback1 u err =
      match Js.Opt.to_option err with
          None -> Lwt.wakeup_later u ()
        | Some err -> Lwt.wakeup_later_exn u (Failure (Js.to_string err##message))

    let bool_callback1 u b = Lwt.wakeup_later u (Js.to_bool b)

    let wrap_async1 callback f =
      let t, u = Lwt.wait () in
        f (Js.wrap_callback (callback u));

    let exists s = wrap_async1 bool_callback1 (fun cb -> fs##exists(Js.string s, cb))
    let unlink s = wrap_async1 err_callback1 (fun cb -> fs##unlink(Js.string s, cb))

    let read_file fname =
      let t, u = Lwt.wait () in

      let on_read err data =
        if Js.Opt.test err then
          Lwt.wakeup_later_exn u (Failure (sprintf "could not read %S" fname))
        else Lwt.wakeup_later u (Js.to_string data##toString())
        fs##readFile(Js.string fname, Js.wrap_callback on_read);
    (* vim: set ft=ocaml: *)

OCaml art exhibition in Venice


Tao Stein announced:
My exhibition opens this May 2 until May 31 at Scuola San Pasquale, Chiesa San
Francesco della Vigna at this year's Biennale Arte.

Everything was made with OCaml -- from the artwork itself to the marketing
materials and posters now posted all over the city.

Welcome to join the vernissage May 9th at 7PM. There will be traditional
Venetian tapas and of course plenty of good wine :)

More here:

Albatross 0.1


Helmut Brandl announced:
I am pleased to announce version 0.1 of the Albatross compiler.

The Albatross compiler suite is written in ocaml v4.0.

What is Albatross?

- A programming language with static verification (allthough version 0.1 is
not yet able to compile real programs)

- A theorem prover and a proof assistant.

Safe UTF-8 string literals and pattern matching for OCaml


Daniel Bünzli announced:
If you ever wanted to have that *safely* you may want to checkout this
experimental ppx:

Here's the design rationale: will expire in 60 days


Richard Jones explained:
... and I don't intend to renew it.  The website has not been working
for a few years, and much of the content moved to

If *an establised person from the OCaml community* wishes to have the
domain name transferred to them, let me know.  Obviously you will need
to accept the renewal fee and any other transfer charges involved.
The domain is currently registered through GANDI.

Other OCaml News

From the ocamlcore planet blog:
Thanks to Alp Mestan, we now include in the OCaml Weekly News the links to the
recent posts from the ocamlcore planet blog at

Gamut Redivivus: OCaml App in iOS Simulator:

Full Time: Software Developer (Functional Programming) at Jane Street in New York, NY; London, UK; Hong Kong:

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