OCaml Weekly News Previous week Up Next week

Hello

Here is the latest OCaml Weekly News, for the week of May 29 to June 05, 2018.

  1. ATD - static types for json APIs, v1.13.0 | new documentation home
  2. llpp v28
  3. First release of PGX (Pure-OCaml PostgreSQL client)
  4. First release of Crlibm
  5. New version of package lbfgs
  6. First opam release of easy_xlsx
  7. Other OCaml News

ATD - static types for json APIs, v1.13.0 | new documentation home

Archive: https://discuss.ocaml.org/t/atd-static-types-for-json-apis-v1-13-0-new-documentation-home/2059/1

Martin Jambon announced:
We've made a lot of internal changes to the ATD suite of tools, including
atdgen. Atdgen is a full-featured program that takes type definitions and
derives OCaml parsers and serializers for json. For example,

```
type hello = {
  greeting : string;
  ?fruit : fruit option;
}

type fruit = [ Peach | Cherry ]
```
results in two OCaml functions of the following types:
```
val hello_of_string : string -> hello
val string_of_hello : greeting:string -> ?fruit:fruit -> unit -> string
```

The purpose of this announcement is primarily to bring the attention of the
community to the existence of this tool, which most people should be using
instead of straight yojson (the parser and AST-handling library on which atdgen
relies).

This is a stable release available from opam, and the changes are mostly
internal. Different tools relying on atd have been consolidated into one repo,
efforts are ongoing to make the codebase more accessible, and [new, exciting
features are being developed](https://github.com/mjambon/atd/issues)!

```
$ opam install atdgen
```

Check out the [documentation's new home](http://atd.readthedocs.io)!

Martin, on behalf of the [ATD team](https://github.com/mjambon/atd/graphs/contributors).
      
Shon then said:
The new documentation looks great :slight_smile:

In my scant use of JSON for OCaml stuff so far, I've primarily relied on
`ppx_deriving_yojson`. Are there use cases for which `atdgen` is inherently
better suited, or is it mainly just a matter of methodological preferences
(e.g., of command line tools and separate file formats over inline annotations)?
      
Martin Jambon replied:
Atdgen is geared toward interoperability between applications.

The main features that distinguish it from its camlp4-based predecessor
[json-static](https://mjambon.github.io/mjambon2016/json-static.html) and from
[ppx_deriving_yojson](https://github.com/ocaml-ppx/ppx_deriving_yojson) are:

* The specification of the ATD language is not tied to the OCaml language.
* Generated code is plain text that's easy for the user to inspect.
* Direct parsing/serializing without going through an AST.

Historically, atdgen was created out of a desire to not depend on the "new
camlp4" released around 2007, which suffered many undocumented changes as well
as unsatisfying build-time performance. Atdgen only needed a small fraction of
the features of camlp4 anyway. Atdgen was developed at that time with a focus of
mapping type definitions to various languages.
      

llpp v28

Archive: https://sympa.inria.fr/sympa/arc/caml-list/2018-05/msg00046.html

moosotc announced:
New version of llpp (tagged llipposuction) is now available at:
* http://repo.or.cz/w/llpp.git
* https://github.com/moosotc/llpp/

============================================================================
Blurb

llpp is a graphical PDF pager, which aims to superficially resemble
less(1)

============================================================================
Links

videos - https://www.youtube.com/watch?v=qNszKpCUXhQ&list=PLLAukRknwSgFhpYsDKHY0oWpvV03Qj4AE
bug tracker - https://github.com/moosotc/llpp/issues

============================================================================
Changes (relative to v27)

* Removed:
  remnants of Microsoft Windows (Cygwin) support
  EGL
  some rarely used keyboard shortcuts
  automatic shell completion generators
  BGR
  vestiges of Make
  altivec memory clearing
  non-persistent bookmarks

* Improved:
  build system
  inotify script (Malte Tammena)
  macOS support

Summary v27..v28
   480	malc
    15	moolc
     2	0xe0f
     2	Malte Tammena
     1	Nicolás Ojeda Bär

Diffstat v27..HEAD
[..snip for brevity..]
74 files changed, 3538 insertions(+), 5063 deletions(-)
      

First release of PGX (Pure-OCaml PostgreSQL client)

Archive: https://discuss.ocaml.org/t/ann-first-release-of-pgx-pure-ocaml-postgresql-client/2068/1

Brendan Long announced:
I'm happy to announce the first release of
[PGX](https://opam.ocaml.org/packages/pgx/) on opam. PGX is a pure-OCaml
PostgreSQL client based on PG'Ocaml.

Since the fork, we've made the following improvements:

- More tests ([80%
  coverage](https://coveralls.io/github/arenadotio/pgx?branch=master) on the
  latest commit)
  - We designed our tests we [write them
    once](https://github.com/arenadotio/pgx/blob/master/pgx_test/src/pgx_test.ml)
    and then run them against
    [all](https://github.com/arenadotio/pgx/blob/master/pgx_async/test/test_pgx_async.ml)
    [three](https://github.com/arenadotio/pgx/blob/master/pgx_lwt/test/test_pgx_lwt.ml)
    [IO](https://github.com/arenadotio/pgx/blob/master/pgx_unix/test/test_pgx_unix.ml)
    backends
  - Tests also [run on every commit](https://circleci.com/gh/arenadotio/pgx)
- More consistent use of async API's (we do our best to never use synchronous API's)
- Addition of
  [Pgx.Value](https://github.com/arenadotio/pgx/blob/master/pgx/src/pgx_value_intf.ml)
  for hopefully easier conversion to and from DB types
- [Safe handling of concurrent
  queries](https://github.com/arenadotio/pgx/blob/0.1/pgx_test/src/pgx_test.ml#L295)
  (not any faster, but they won't crash)
- [Improved interface for prepared
  statements](https://github.com/arenadotio/pgx/blob/0.1/pgx/src/pgx.mli#L202) to
  [make it harder to use them
  wrong](https://github.com/arenadotio/pgx/blob/0.1/pgx_test/src/pgx_test.ml#L230)
- We include Pgx_async, Pgx_lwt, and Pgx_unix (synchronous) so you don't have to
  write your IO module (and possibly get it wrong)
- Probably other things I've forgotten by now

We're still looking for feedback on the API and pull requests are welcome!
      

First release of Crlibm

Archive: https://discuss.ocaml.org/t/ann-first-release-of-crlibm/2079/1

Christophe announced:
I am happy to announce the first release of
[crlibm](https://opam.ocaml.org/packages/crlibm/), a binding to the _proved_
correctly-rounded mathematical library
[CRlibm](https://web.archive.org/web/20161027224938/http://lipforge.ens-lyon.fr/www/crlibm).
For most of the usual functions, this library provides 4 versions, one rounded
to the nearest, one rounded up, one rounded down and one rounded towards zero.
Here is an example:
```ocaml
#require "crlibm";;
~/.opam/4.06.1/lib/crlibm: added to search path
~/.opam/4.06.1/lib/crlibm/crlibm.cma: loaded
# pi;;
- : float = 3.14159265358979312
# Crlibm.cos pi;;
- : float = -1.
# Crlibm.Low.cos pi;;
- : float = -1.
# Crlibm.High.cos pi;;
- : float = -0.999999999999999889
# Crlibm.Zero.cos pi;;
- : float = -0.999999999999999889
```
The project is [hosted on Gihub](https://github.com/Chris00/ocaml-crlibm).
      

New version of package lbfgs

Archive: https://discuss.ocaml.org/t/ann-new-version-of-package-lbfgs/2080/1

Christophe announced:
It is my pleasure to announce a new release of
[lbfgs](https://github.com/Chris00/L-BFGS-ocaml), a binding to Nocedal's
[implementation](http://users.eecs.northwestern.edu/%7Enocedal/lbfgsb.html) of
the
[Broyden–Fletcher–Goldfarb–Shanno](https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm)
(BFGS) algorithm using a limited amount of computer memory with the possibility
of setting bounds on the variables. The purpose of this algorithm is to solve
large-scale nonlinear optimization problems. Here are some [elementary examples
of use](https://github.com/Chris00/L-BFGS-ocaml/tree/master/examples). I hope
you will find this library useful.
      

First opam release of easy_xlsx

Archive: https://discuss.ocaml.org/t/ann-first-opam-release-of-easy-xlsx/2082/1

Brendan Long announced:
I'm pleased to announce the first release of
[easy_xlsx](http://opam.ocaml.org/packages/easy_xlsx/) and some related
lower-level libraries
([spreadsheetml](http://opam.ocaml.org/packages/spreadsheetml/spreadsheetml.1.0/)
to parse the contents of an XLSX file, and
[open_packaging](http://opam.ocaml.org/packages/open_packaging/open_packaging.1.0/)
to parse Microsoft's "Open Packaging Specification", which is used by all new
Microsoft Office formats).

See [documentation
here](https://brendanlong.github.io/ocaml-ooxml/doc/easy_xlsx/Easy_xlsx/index.html)

The short version is that if you need to read a .xlsx file, you can do:

```
Easy_xlsx.read_file "example.xlsx"
|> List.iter (fun sheet ->
  printf "Got sheet: %s\n" (Easy_xlsx.name sheet);
  Easy_xlsx.rows sheet
  |> List.iter (fun row ->
    List.iter (function
      | Easy_xlsx.Value.Date d -> (* Ptime.date *)
      | Datetime dt -> (* Ptime.t *)
      | Number n -> (* float *)
      | String s -> (* a string obviously *)
      | Time t -> (* Ptime.time *))))
```

(There's also a `Easy_xlsx.Value.to_string` if you just want to convert XLSX to CSV)

If you have any XLSX files that don't work right and can make them public,
please open a pull request to add them to the test suite. Detecting datetimes is
surprisingly complicated since it depends on the formatting applied to the
column (datetimes are identically to numbers), so if you're dealing with unusual
formatting I may not be able to detect it, but having more examples in the test
suite would help.
      
cfcs asked:
That is very nice!

I must admit that my main use for generating Excel files in the past has been
that the CSV format's method to specify background colors for cells was pretty
buggy and not portable between Excel/LibreOffice, so I'm not a heavy user, but I
think this is good to have in the ecosystem!
      
Brendan Long then replied:
At the moment I don't really offer an interface to write XLSX files back out,
but I'd be happy to have it.

`spreadsheetml` is able to expose [cell
styles](https://github.com/brendanlong/ocaml-ooxml/blob/master/spreadsheetml/src/styles.mli)
but it's not exposed at the `easy_xlsx` layer (since that library is meant more
for data processing. I'd like to have a more mid-level interface at some point,
where we expose the full content of the cells instead of just the data.
      

Other OCaml News

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

Frama-C 17 - Chlorine is out. Download ithere.
 http://frama-c.com/index.html

An OCaml quine | Drup's thingies
 https://drup.github.io/2018/05/30/quine/

Full Time: Compiler Engineer at Jane Street in New York & London
 http://jobs.github.com/positions/9e8ba450-e72e-11e7-926f-6ce07b7015c8

Full Time: Software Developer (Functional Programming) at Jane Street in New York, NY; London, UK; Hong Kong
 http://jobs.github.com/positions/0a9333c4-71da-11e0-9ac7-692793c00b45
      

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