[cwn] Attn: Development Editor, Latest OCaml Weekly News

Alan Schmitt alan.schmitt at polytechnique.org
Tue May 17 06:02:03 PDT 2016


Hello,

Here is the latest OCaml Weekly News, for the week of May 10 to 17, 2016.

1) Simple library to manipulate automata?
2) IDE like PyCharm - Results
3) Ocaml and Windows' notion of Unicode file names
4) Batteries 2.5.0, compatible with OCaml 4.03
5) BuckleScript (A js backend for ocaml)
6) Next OUPS meetup, 7th of June 2016
7) Ocaml Github Pull Requests
8) Other OCaml News

========================================================================
1) Simple library to manipulate automata?
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00058.html>
------------------------------------------------------------------------
** David Mentré asked:

I would like to manipulate some basic automata in OCaml: creation, execution,
minimization, display, etc.

Before re-inventing the wheel, do you know a library doing that?

From my own searches, I only found "automatx"
(<http://pauillac.inria.fr/~quercia/>) which seems to suit my needs but (1) has
a French API and (2) has no license information.
      
** Török Edwin replied:

There is safa/symkat on opam [1]. It has various automata minimization
algorithms, NFA -> DFA, print to .dot format.
Although it is meant for equivalence checking, so it may not be 'simple' to use
for actually executing the automata, and beware that the syntax for its parser
is not the usual regex [2].
(of course you can construct the automata with the API instead of parsing from a
string to avoid this).

See below for some code that I wrote a while ago to visualize a DFA using
safa/symkat:

[1] <http://perso.ens-lyon.fr/damien.pous/symbolickat/>
[2] <http://perso.ens-lyon.fr/damien.pous/symbolickat/symkat.docdir/Parse.html>

(*
 * $ ocamlfind ocamlopt printnfa.ml -package safa,symkat -o printnfa -linkpkg -rectypes
 * $ ./printnfa >test.dot
 * NFA states: 7
 * DFA states: 5
 * $ dot -Tsvg test.dot -o test.svg
 * $ firefox ./test.svg
 *)
let trace_dfa a states =
  let trace = Automata.SDFA.trace Format.pp_print_char Format.pp_print_char
      (Bdd.print_formula 0) in
  Trace.clear ();
  trace a states;
  print_endline (Trace.render false "\"")

let print_nfa x =
  let a,f = Automata.SNFA.reindex (Antimirov.nfa()) in
  let states = f (Antimirov.split x) in
  let number_of_states, _ = Automata.SNFA.size a states in
  Printf.eprintf "NFA states: %d\n%!" number_of_states;
  let a = Determinisation.optimised a in
  let number_of_states, _ = Automata.SDFA.size a [states] in
  trace_dfa a states; 
  Printf.eprintf "DFA states: %d\n%!" number_of_states

let print_dfa x =
  let a = Brzozowski.dfa () in
  let number_of_states, _ = Automata.SDFA.size a [x] in
  Printf.eprintf "DFA states: %d\n" number_of_states

let () =
  let e = Parse.expr "x*x*x*x*x*(x+y)z" in
  let x,_,_ = Hypotheses.eliminate [] e e in
  print_nfa x;
      
** Spiros Eliopoulos also replied:

Two libraries come to mind. I and others on the Frenetic[0] team have used both
at various points in time to implemented automata-related algorithms. The first
is a project called DPRLE. You can find its home page and my GitHub clone of the
SVN repository below:

<http://www.cs.virginia.edu/~ph4u/dprle/>
<https://github.com/seliopou/dprle>

The second is a library that I wrote called TDK. It implements a generalization
of BDDs, allowing for variables to have a lattice structure and terminal nodes
to have something like a semi-ring structure. You can find the GitHub repository
here:

<https://github.com/frenetic-lang/ocaml-tdk>

Last I checked, TDK is on OPAM, while DPRLE is not. Hope this helps!

-Spiros E.

[0]: <http://frenetic-lang.org>
      
========================================================================
2) IDE like PyCharm - Results
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00063.html>
------------------------------------------------------------------------
** Continuing the thread from last week, Benjamin Greenman said:

You might like Sublime Text <https://www.sublimetext.com/> with
whitequark's <https://github.com/whitequark/sublime-better-ocaml>
extensions.
      
** Leonardo Laguna Ruiz also replied:

If you are willing to try one more alternative, I use Sublime Text 3 plus the
plugin of merlin.

<https://www.sublimetext.com/3>
<https://github.com/cynddl/sublime-text-merlin>

I use this project "template" in every project I start.

<https://github.com/modlfo/ocaml-sublimetext-template>

Merlin through sublime text works quite well. The only problem I have had is
with projects of tens of thousands lines of code, the autocomplete gets slow. In
such cases I turn it off.

Sublime text is an excellent editor. Looks a lot like Atom but Sublime text is
much faster and responsive.
      
========================================================================
3) Ocaml and Windows' notion of Unicode file names
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00126.html>
------------------------------------------------------------------------
** Andreas Rossberg asked:

Does anybody have advice for dealing with unicode file names under Windows? In
particular, my problem is that the following invariant

  let files = Array.to_list (Sys.readdir ?.?) in
  assert (List.for_all Sys.file_exists files)

does not hold under Windows, because some of the file names returned by readdir
are not valid.

The Unix emulation module has the same issue.

This is only partially Ocaml?s fault ? I see that it implements Sys.readdir and
Unix.readdir using Windows? ASCII _findfirst and _findnext functions, which
apparently just replace large code points with ???. And I?m not sure how
realistic it would be for Ocaml to switch to Windows' wchar APIs and, say,
UTF8-encode/decode file names on its side.

But anyway, I?m wondering who else has run into this, and has an idea how to
cope. Because I came up blank.
      
** Adrien Nader replied:

There was a thread about this back in february:
  "Looking for a windows ocaml UTF-16 encoded filename aware library".
      
** Matthieu Dubuget then added:

the thread pointed by Adrien lists different solutions. One of them is to write
a lightweight unicode-aware library. A cleaner solution is also currently
proposed as a pull request against OCaml standard library
(<https://github.com/ocaml/ocaml/pull/153>).

I tried the "small library" solution, which worked pretty well, but in my
use-case, it appeared to be extremely slow. I did not yet test a mixed solution,
that would switch to unicode versions of the calls, only when the non-unicode
one are failing. Nor did I tried yet the pull request #153.

Note that on windows, there are two different problems to address when dealing
with paths. The more obvious one is their encoding. But you may also experience
problems depending on their length. In this case, the solution is to use
unicode-aware calls, and to specify an extended-length path, using the "\\?\"
prefix. For example, "\\?\D:\very long path". I also have to check if this is
slower.
      
========================================================================
4) Batteries 2.5.0, compatible with OCaml 4.03
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00082.html>
------------------------------------------------------------------------
** Gabriel Scherer announced:

## Batteries

Batteries Included is a community-maintained standard library
extension, with a focus on stability and compatibility. Bug reports,
pull requests and other contributions are warmly welcome, see the
project page at
  <https://github.com/ocaml-batteries-team/batteries-included/>

The library's API documentation at:
  <http://ocaml-batteries-team.github.io/batteries-included/hdoc2/>

Batteries 2.5.0 is a minor release, coming shortly after 2.4.0
released in December 2015. The main change in 2.5.0 is that it is
compatible with the newly released OCaml 4.03.

Note that, as usual for Batteries release, Batteries 2.5.0 is
compatible with older OCaml releases as well, and provides back-ported
versions of most standard library functions made available in 4.03
only. For example, BatString.uppercase_ascii is usable under all OCaml
versions.

If the documentation of a Batteries function says
  @since 2.5.0
then it is available under all supported OCaml versions (3.12.1 and
up). If it says
  @since 2.5.0 and OCaml 4.03.0
then it is only available under OCaml 4.03.0.

Many thanks to the contributors for this release, Cedric Cellier,
Pieter Goetschalckx KC Sivaramakrishnan, Gabriel Scherer, and Thibault
Suzanne.

## Detailed Changelog

- BatTuple: add Tuple{N}.make : 'a1 -> ... -> 'an -> 'a1 * ... * 'an
  #657
  (Thibault Suzanne)
- BatBig_int: fix sequence operators (--), (---) to avoid polymorphic comparison
  #674, #675, #676
  (Pieter Goetschalckx and Cedric Cellier)
- Extend all Batteries module to cover OCaml 4.03 features
  #670
  (Gabriel Scherer, KC Sivaramakrishnan)

## Future plans

OCaml 4.03 introduced a type `('a, 'b) result` contributed by Yaron
Minsky, meant to serve as common denominator between the various
libraries relying on some kind of sum/either type.

    type ('a,'b) result = Ok of 'a | Error of 'b

Batteries has long had its own `result` type, which unfortunately uses
a different name for the second constructor:

    type ('a, 'b) result = Ok  of 'a | Bad of 'b

Unfortunately, this means that the two types are incompatible (see
PR#7102 for a feature request on renaming variant
constructors). Batteries 2.5.0 is compatible with previous Batteries
versions, and keeps using Batteries' result type.

Of course, the right long-term move for Batteries is to drop its own
result type and use the standard result type instead. But this means
a breaking change for our users as well. We plan to make a major
release 3.0 in the following months, that integrates this breaking
changes and some other incompatible interface changes that were
proposed over the 2.x lifetime.

Happy hacking!
      
** Christoph Höger asked, Matej Kosik added, and Gabriel Scherer replied:

>> Unfortunately, I am unable to use some modules:
>>
>> consider the following simple test:
>>
>> % cat foo.ml
>> let () = Printf.printf "%s\n" Batteries.Sys.os_type
>> % ocamlbuild -pkg batteries foo.native
>> ...
>> File "_none_", line 1:
>> Error: No implementations provided for the following modules:
>>          BatConcreteQueue_402 referenced from
>> [..]/opam/4.02.3/lib/batteries/batteries.cmxa(BatQueue)
>>          BatOpaqueInnerSys referenced from
>> [..]/opam/4.02.3/lib/batteries/batteries.cmxa(BatSys)
>> Command exited with code 2.
>>
>> This is opam 1.2.2, OCaml 4.02.3 and batteries 2.5.0
>>
>> Did I break something or is this an actual bug?

> In my context, after switching to 4.02.3, I noticed the same problem.

There is indeed a packaging problem with 2.5.0 -- I did two quick
bugfix releases in succession, and 2.5.2 should land in opam any time
now. Apologies for the hiccup.
      
========================================================================
5) BuckleScript (A js backend for ocaml)
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00083.html>
------------------------------------------------------------------------
** Hongbo Zhang announced:

Dear OCaml developers:
We are glad to announce BuckleScript[1], a backend for the OCaml compiler which
emits JavaScript. The project's goal is to bridge the OCaml and JavaScript
ecosystems in a seamless way. As examples of that vision, using BuckleScript,
OCaml users can use Chrome Dev Tools to debug OCaml code, while Javascript users
can use OCaml libraries as plain npm[2] packages. 
The project is inspired by js_of_ocaml[3], and the differences are documented
here[4]. While it is not production-ready yet, we've reached a point in the
development where we feel comfortable encouraging you to try it and 
share your feedback with us. 

[1]: <https://github.com/bloomberg/bucklescript/> 
[2]: <https://www.npmjs.com/>
[3]: <http://ocsigen.org/js_of_ocaml/>
[4]: <https://bloomberg.github.io/bucklescript/Differences-from-js_of_ocaml.html> 
      
========================================================================
6) Next OUPS meetup, 7th of June 2016
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2016-05/msg00119.html>
------------------------------------------------------------------------
** Louis Roché announced:

The next OUPS meetup will take place on the 7th of June 7pm. The location is not
defined yet.
We will have a few talks, followed by pizzas.

The talks will be the following:

- Danny Willems: Bindings OCaml à Cordova grâce à js_of_ocaml et gen_js_api 
- Frédéric Bour: sturgeon ? A toolkit for communicating with Emacs from OCaml

Note that we are always in demand of talk *proposals* for future
meetups.

To register, or for more information, go here:
<http://www.meetup.com/fr-FR/ocaml-paris/events/231068590/>
*Registration is required!*

Slides from previous sessions are available online:
<http://www.meetup.com/fr-FR/ocaml-paris/files/>
      
========================================================================
7) Ocaml Github Pull Requests
------------------------------------------------------------------------
** Gabriel Scherer 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.

Make OCaml native debugging awesome
<https://github.com/ocaml/ocaml/pull/574>
      
========================================================================
8) Other OCaml News
------------------------------------------------------------------------
** From the ocamlcore planet blog:

Here are links from many OCaml blogs aggregated at OCaml Planet,
<http://ocaml.org/community/planet/>.

OCaml 4.03.0 released
 <http://caml.inria.fr/pub/distrib/ocaml-4.03/>

Tail call optimisation in (g)awk
 <http://blog.0branch.com/posts/2016-05-13-awk-tco.html>

Batteries 2.5.0 released, compatible with OCaml 4.03
 <http://forge.ocamlcore.org/forum/forum.php?forum_id=932>

Configuration DSL step-by-step
 <https://hannes.nqsb.io/Posts/Functoria>
      
========================================================================
Old cwn
------------------------------------------------------------------------

If you happen to miss a CWN, you can send me a message
(alan.schmitt at polytechnique.org) and I'll mail it to you, or go take a look at
the archive (<http://alan.petitepomme.net/cwn/>) or the RSS feed of the
archives (<http://alan.petitepomme.net/cwn/cwn.rss>). If you also wish
to receive it every week by mail, you may subscribe online at
<http://lists.idyll.org/listinfo/caml-news-weekly/> .

========================================================================

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2015-04: 403.26, 2016-04: 407.42
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/caml-news-weekly/attachments/20160517/afc602f6/attachment.pgp>


More information about the caml-news-weekly mailing list