Previous week Up Next week

Hello

Here is the latest OCaml Weekly News, for the week of March 21 to 28, 2017.

  1. OCaml on the benchmarks game
  2. Exceptions and Gc.
  3. Open 18-month Research Engineer Position on Frama-C/E-ACSL
  4. Transforming side-effects to a monad
  5. Loading .ml in memory to interact with them.
  6. React.js programming in OCaml?
  7. first release of minivpt: a minimalist vantage-point tree implementation in OCaml
  8. BuckleScript 1.6
  9. Ocaml Github Pull Requests
  10. Other OCaml News

OCaml on the benchmarks game

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00082.html

Isaac Gouy announced:
It's been too many years since I mentioned that new and improved OCaml programs
would be welcome contributions to the benchmarks game.

Here are the existing programs:

    http://benchmarksgame.alioth.debian.org/u64q/measurements.php?lang=ocaml

Here are instructions on how to contribute a program:

    http://benchmarksgame.alioth.debian.org/play.html
      

Exceptions and Gc.

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00083.html

Continuing this thread, Gabriel Scherer announced:
By the way, the unloading patch is now merged. (In trunk; it should not be part
of the 4.05 release in preparation, but of 4.06 that should hopefully happen six
months after that.)
      

Open 18-month Research Engineer Position on Frama-C/E-ACSL

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00084.html

Julien Signoles announced:
The Software Reliability Lab at CEA LIST (Paris Saclay, France) is hiring a
18-month research engineer to improve the Frama-C runtime verification plug-in
E-ACSL.

A full description of the open position is available online:
http://julien.signoles.free.fr/eacsl_engineer.pdf.

Feel free to contact me for additional details
      

Transforming side-effects to a monad

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00095.html

Christoph Höger asked:
this is not entirely OCaml related, but somewhat more general. However,
I hope that someone on that list can give me a pointer on how to proceed.

Assume a simple OCaml program with two primitives that can cause
side-effects:

let counter = ref 0
let incr x = counter := !counter + x ; !counter
let put n = counter := n; !counter
put (5 + let f x = incr x in f 3)

This example can be transformed into a pure program using a counter
monad (using ppx_monadic syntax):

do_;
  i <-- let f x = incr x in f 3 ;
  p <-- put (5 + i)
  return p

For a suitable definition of bind and return, both programs behave
equivalently. My question is: How can one automatically translate a
program of the former kind to the latter? I assume, one needs a normal
form that makes the order of evaluation explicit, but which normal form
would that be? Is there a textbook algorithm for that kind of analysis?

any pointers are appreciated
      
Jeremy Yallop replied:
You might be interested in the following paper, which describes
exactly such a translation:

   Lightweight Monadic Programming in ML
   Nikhil Swamy, Nataliya Guts, Daan Leijen, and Michael Hicks
   ICFP 2011
   https://www.cs.umd.edu/~mwh/papers/swamy11monad.html
      

Loading .ml in memory to interact with them.

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00106.html

Deep in this thread, Oleg said:
> The problem here is that echo (or printf) closes the pipe_in fifo,
> hence sending EOF to the ocaml toplevel. You need to force the fifo to
> somehow remain open.

Eons ago, back in the last century, I wrote a simple tool for that task
        http://okmij.org/ftp/Communications.html#sh-agents
to script almost anything from really anything. I used it to drive
Mathematica (on a remote machine) from Emacs and database CLI tools.

(I just realized it has been 20 years...)
      

React.js programming in OCaml?

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00110.html

Kenichi Asai asked:
What is the best way to do react.js programming as introduced in

https://facebook.github.io/react/

in OCaml?  I found the tutorial on the above page written very well,
and I want to do the same thing in OCaml at the similar abstraction
level as in JS.  Any information is welcome.  Thanks in advance.
      
David Teller replied then Daniel Bünzli said:
> If I recall correctly, React.js is actually a JS port of the following
> OCaml library: http://erratique.ch/software/react
> 
> So that might be what you're looking for :)
 
I don't think so AFAIK react.js has nothing to do with functional reactive
programming.
      
Zhi An Ng also replied:
The closest thing I know is reason-react, reason is facebook's sugar syntax for
ocaml for the web. Bucklescript, is another javascript backend for ocaml, and
has interop with javascript libraries.

I think the main difference is that [0] allows you to write JSX.

[0] https://github.com/reasonml/reason-react
[1] https://github.com/bloomberg/bucklescript/
      
Hongbo Zhang then said:
Indeed, OCaml actually has the official support of ReactJS bindings provided by
Facebook's Reason team and Bloomberg's BuckleScript compiler. According to React
Conf 2017, it is used in production for already half a year and powered a quite
large piece of components in FB's messenger.com Note ReasonML provides JSX
syntax which is more familiar to ReactJS users, but you can use either Reason
syntax or vanilla OCaml syntax.
      

first release of minivpt: a minimalist vantage-point tree implementation in OCaml

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00115.html

Francois Berenger announced:
A vantage point tree allows to do fast (but exact) nearest neighbor searches in
a space of any dimension provided that you have a distance function (to measure
the distance between any two points in that space).

The code is here:
https://github.com/UnixJunkie/vp-tree

The interface looks like this:
---
type 'a t

val create: ('a -> 'a -> float) -> 'a list -> 'a t

val nearest_neighbor: ('a -> 'a -> float) -> 'a -> 'a t -> float * 'a

val to_list: 'a t -> 'a list

val is_empty: 'a t -> bool
---

The creation of a vp-tree can take some time.
Queries are supposed to be fast.
In my tests, queries can run several times faster than a brute
force search once you have enough points indexed by your vpt.

The implementation creates an optimal vp-tree; don't use it
on large points set (> 10,000 points).

You can install it via:
$ opam install minivpt

Contributions are very welcome to support large point sets, queries
with a tolerance parameter (as in "only points within distance to query
less than the tolerance"), and returning all points (instead of just one) if
there are several points within the same distance to your query point.

A usage example might be:
---
let vpt = Vp_tree.create distance_fun points in
let dist_to_query, nearest_point = \
Vp_tree.nearest_neighbor distance_fun query_point vpt in
[...]
---

My implementation follows the paper:
"Data Structures and Algorithms for Nearest Neighbor Search in General Metric
Spaces" by Peter N. Yianilos.
      

BuckleScript 1.6

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2017-03/msg00116.html

Hongbo Zhang announced:
BuckleScript is an optimizing compiler for OCaml to generate readable
JavaScript, it is open sourced by Bloomberg [1].

We are glad to announce 1.6.0, since release 1.5, we have seen significant
external contributions
https://github.com/bloomberg/bucklescript/pulse/monthly, some of them are even
new to OCaml, this is fantastic! Also there is an small group of people who are
actively working on bindings and utilties: https://github.com/BuckleTypes

This release is mostly bug fixes and performance improvement to the build
system, most visible changes:

# Thanks to @glennsl, we have a nice documentation page for the Js bindings:
http://bloomberg.github.io/bucklescript/api/Js.html (Note this is still work in
progress)
# Much faster build even for `bsb -make-world`, the build system is now
re-entrant.
# All error messages from the compiler and build are colorful

Documentation is available here:
http://bloomberg.github.io/bucklescript/Manual.html

To install:
npm install -g bs-platform
Happy hacking in OCaml! -- Hongbo

[1]: https://github.com/bloomberg/bucklescript/ 
      

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.

- Add compiler support for raw pointers
  https://github.com/ocaml/ocaml/pull/724
- Make process creation robust against duplicate descriptors
  https://github.com/ocaml/ocaml/pull/1105
- Fix PR6638: "unused open" warning was incorrectly suppressed by "open!"
  https://github.com/ocaml/ocaml/pull/1110
- Branchless computation of the integer absolute value
  https://github.com/ocaml/ocaml/pull/1113
- Support inherited field in object type expression
  https://github.com/ocaml/ocaml/pull/1118
- injective mapping between identifiers and printed names
  https://github.com/ocaml/ocaml/pull/1120
- Universal do..done
  https://github.com/ocaml/ocaml/pull/1122
- Remove global variables in hash.c
  https://github.com/ocaml/ocaml/pull/1123
      

Other OCaml News

From the ocamlcore planet blog:
Here are links from many OCaml blogs aggregated at OCaml Planet,
http://ocaml.org/community/planet/.

Polynomials over rings
 http://blog.shaynefletcher.org/2017/03/polynomials-over-rings.html
      

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