Here is the latest OCaml Weekly News, for the week of October 14 to 21, 2014.
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00070.htmlDamien Doligez announced:
We have the pleasure of announcing the release of OCaml version 4.02.1. This is all about speed: not only this release fixes a large slowdown in the compiler, but today is also the anniversary of the first time a man broke the sound barrier with an airplane. This is mainly a bug-fix release, see the list of changes below. It is available here: < http://caml.inria.fr/download.en.html > This is released as source on our web site, but the OPAM switch will be available very soon (in a few minutes). Happy hacking, -- Damien Doligez for the OCaml team. OCaml 4.02.1: ------------- (Changes that can break existing programs are marked with a "*") Standard library: * Add optional argument ?limit to Arg.align. - PR#4099: Bug in Makefile.nt: won't stop on error (George Necula) - PR#6181: Improve MSVC build (Chen Gang) - PR#6207: Configure doesn't detect features correctly on Haiku (Jessica Hamilton) - PR#6466: Non-exhaustive matching warning message for open types is confusing (Peter Zotov) - PR#6529: fix quadratic-time algorithm in Consistbl.extract. (Xavier Leroy, Alain Frisch, relase-worthy report by Jacques-Pascal Deplaix) - PR#6530: Add stack overflow handling for native code (OpenBSD i386 and amd64) (Cristopher Zimmermann) - PR#6533: broken semantics of %(%) when substitued by a box (Benoît Vaugon, report by Boris Yakobowski) - PR#6534: legacy support for %.10s (Benoît Vaugon, Gabriel Scherer, report by Nick Chapman) - PR#6536: better documentation of flag # in format strings (Damien Doligez, report by Nick Chapman) - PR#6544: Bytes and CamlinternalFormat missing from threads stdlib.cma (Christopher Zimmermann) - PR#6546: -dsource omits parens for `List ((`String "A")::) in patterns (Gabriel Scherer, report by Peter Zotov) - PR#6547: __MODULE__ aborts the compiler if the module name cannot be inferred (Jacques Garrigue, report by Kaustuv Chaudhuri) - PR#6549: Debug section is sometimes not readable when using -pack (Hugo Heuzard, review by Gabriel Scherer) - PR#6553: Missing command line options for ocamldoc (Maxence Guesdon) - PR#6554: fix race condition when retrieving backtraces (Jérémie Dimino, Mark Shinwell). - PR#6557: String.sub throws Invalid_argument("Bytes.sub") (Damien Doligez, report by Oliver Bandel) - PR#6562: Fix ocamldebug module source lookup (Leo White) - PR#6563: Inclusion of packs failing to run module initializers (Jacques Garrigue, report by Mark Shinwell) - PR#6564: infinite loop in Mtype.remove_aliases (Jacques Garrigue, report by Mark Shinwell) - PR#6565: compilation fails with Env.Error(_) (Jacques Garrigue and Mark Shinwell) - PR#6566: -short-paths and signature inclusion errors (Jacques Garrigue, report by Mark Shinwell) - PR#6572: Fatal error with recursive modules (Jacques Garrigue, report by Quentin Stievenart) - PR#6578: Recursive module containing alias causes Segmentation fault (Jacques Garrigue) - PR#6581: Some bugs in generative functors (Jacques Garrigue, report by Mark Shinwell) - PR#6584: ocamldep support for "-open M" (Gabriel Scherer, review by Damien Doligez, report by Hezekiah M. Carty) - PR#6588: Code generation errors for ARM (Mark Shinwell, Xavier Leroy) - PR#6590: Improve Windows (MSVC and mingw) build (Chen Gang) - PR#6599: ocamlbuild: add -bin-annot when using -pack (Christopher Zimmermann) - PR#6602: Fatal error when tracing a function with abstract type (Jacques Garrigue, report by Hugo Herbelin) - ocamlbuild: add an -ocamlmklib option to change the ocamlmklib command (Jérôme Vouillon)Anil Madhavapeddy then added:
There are now also updated binary packages for OCaml 4.02.1, Camlp4 and OPAM available for Debian, Ubuntu, Fedora, RHEL and CentOS, from: http://software.opensuse.org/download.html?project=home%3Aocaml&package=ocaml Since ARM is a little slower than the speed of sound, those on embedded devices may also find the armhf binary packages useful in the Launchpad PPAs. There are specific PPAs for combinations of OCaml and OPAM at: https://launchpad.net/~avsm Instructions on how to install these binary packages on various distributions are available from: http://ocaml.org/docs/install.html The OPAM Travis tests (which uses the Ubuntu Launchpad PPAs above) will only be testing 4.02.1 from now on for the 4.02.x test matrix. Please let me know if you specifically need 4.02.0 tested for some reason.
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00074.htmlYoriyuki Yamagata announced:
I am pleased to announce "uproplib", a library which provides access to Unicode Character Database (UCD). https://github.com/yoriyuki/uproplib/releases/tag/v0.0.1 UCD is compiled into the binary of the library itself, so, unlike camomile, you do not need to specify the location of data files. The size of the library is about 3M bytes on my Mac, but since each property is packaged as a separate module, you only need to link the properties which you need. uproplib contains all UCD properties except Unihan properties. To compile uproplib, you need ucorelib and Daniel Bünzli 's uucd, in addition to standard ocaml and Unix tools. This is very early alpha release. There is no documentation, no opam package, and even no test :-)
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00076.htmlGerd Stolpmann announced:
a new minor version has been released. There is a new ppxopt META variable allowing to pass options to ppx rewriters (for toploop use, ocaml-4.02.1 is required). This variable allows to set options for required ppx packages (e.g. ppxopt="pkg1,foo pkg2,bar" passes option foo to the ppx rewriter in package pkg1, and bar to the ppx rewriter defined in pkg2). Also, a new environment variable FINDLIB_TOOLCHAIN was added. Both changes were developed by Peter Zotov (thanks for this). As always, links for download can be found here: http://projects.camlcity.org/projects/findlib.html
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00080.htmlRoelof Wobben asked and Stefan Schmiedl replied:
> What is a good online book for a beginner to learn Ocaml with a lot of > exercises. I recommend John Whitington's books, available as DRM-free PDF at http://ocaml-book.com/ (not free, but worth every penny).Malcolm Matalka also replied:
http://blog.nullspace.io/beginners-guide-to-ocaml-beginners-guides.htmlMario Alvarez Picallo also replied:
John Whitington's books are excellent resources for beginners. You might also want to consider Real World OCaml, which is freely available at https://realworldocaml.org/Francois Berenger also replied:
There are also some simple online exercises: http://try.ocamlpro.com/
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00085.htmlYaron Minsky announced:
Jane Street is actively hiring summer interns for our offices in New York, London and Hong Kong. Interning at Jane Street is a great learning experience. If you're interested in seeing how functional programming is applied to real world problems at big scale, there's no better place. Look here https://blogs.janestreet.com/?p=962 to get a sense of the kinds of projects summer interns do. As is reflected there, many of our intern projects make their way out as open-source projects. Interns also learn about Jane Street's trading business through lectures and interactive training sessions. Plus, there are a lot of fun social activities throughout the summer. Feel free to redistribute this to any students you think might be interested. And if you're interested directly, you can apply here: http://janestreet.com/apply And as usual, we're also hiring developers for fulltime positions in NYC, Hong Kong and London.
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00087.htmlShayne Fletcher asked:
In 1994, Barton and Nackman in their book 'Scientific Engineering in C++'  demonstrated how one could encode the rules of Dimensional Analysis  into the C++ type system enabling compile-time checking (no runtime-cost) of the plausibility (at least up to the dimensional correctness) of computations. In 2004, Abrahams & Gurtovy in 'C++ Template Metaprogramming'  showed the Barton Nackman technique to be elegantly implementable using compile time type sequences encoding integer constants. At the end of this post, I provide a complete listing of their example program . The key properties of the system (as I see it) are: - Encoding of integers as types; - Compile time manipulation of sequences of these integer encodings to deduce/produce new derived types. Now, it is not immediately obvious to me how to approach this problem in OCaml. It irks me some that I can't immediately produce a yet more elegant OCaml program for this problem and leaves me feeling like C++ has "got something over on us" here ;) My question therefore is: Does anyone have suggestions/pointers on how to approach automatic dimensional analysis via the OCaml type system? Best, -- Shayne Fletcher  John J. Barton and Lee R. Nackman. Scientific and Engineering C++: an Introduction with Advanced Techniques and Examples. Reading, MA: Addison Wesley. ISBN 0-201-53393-6. 1994.  Wikipedia http://en.wikipedia.org/wiki/Dimensional_analysis  David Abrahams and Aleksey Gurtovy C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series), Addison-Wesley Professional. ISBN:0321227255. 2004.  Code listing: see https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00087.htmlRoberto Di Cosmo replied:
you might have a look at the thread answering a similar question I asked last june on the list, here: https://sympa.inria.fr/sympa/arc/caml-list/2014-06/msg00066.html Notice that the very first viable experiment of a variant of CamlLight with full dimension types (non encodings) was announced by Bruno Blanchet back in 1995 http://caml.inria.fr/pub/ml-archives/caml-list/1995/12/2c6fa7b3b2b429cf39f10b60d2230850.fr.html
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00099.htmlPeter Zotov announced:
I'm glad to announce opam-android, a cross-toolchain for Android based on OCaml 4.02.1. The goals of this port was to minimize the changes to the OCaml compiler, to simplify porting packages as much as possible, to support compile-time components like ppx rewriters or cstubs, and to make using it as simple as possible. I believe I have achieved these goals. In particular, I want to highlight that both bytecode and native code compiling works, -output-obj works and can be used to emit .o and .so files, and using the toolchain is as simple as passing -toolchain android to your ocamlfind invocation (or even setting the OCAMLFIND_TOOLCHAIN environment variable). For further details and installation instructions, please refer to the GitHub project page: https://github.com/whitequark/opam-android
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00114.htmlJohn Whitington announced:
OCaml 4.02 has new facilities for installing a new backtrace handler, and processing the back trace symbolically. As a little proof of concept, I've built a package which you can add to any project to get backtrace with source code printed and highlighted: https://github.com/johnwhitington/exn-source Here's the start of a backtrace: http://www.coherentpdf.com/exnsource.png By default, it prints five lines either side, and looks the current directory for source code. But as one can see from the screenshot, one can add /usr/local/lib/ocaml to get stdlib source and so on... It's somewhat difficult to test this kind of thing (we can't use exceptions at all inside a backtrace handler, for example), so I'm appealing for help. Attach exn-source to your code and let me know how you get on...Gabriel Scherer replied:
That looks like a nice project ! Another trick I use personally is to run the faulting program from inside Emacs's compile-mode (using "build && run" instead of just "build" as a compilatoin command), and piggy-back on its parsing of OCaml error locations to ask Emacs to drive me around the relevant files. I'm sure there are scenarios where your simultaneous view of all fragments at once can be very helpful, and I'm also interested in the uses of the new backtrace/callstack inspection API. > (we can't use exceptions at all inside a backtrace handler, for > example) I'm a bit surprised by this. Part of the point of reifying traces into datatypes (raw_backtrace, backtrace_slot) was to make them persistent. set_uncaught_exception_handler is passed a raw trace that should not be mutated by raising new exceptions. What breaks if you use exceptions inside a backtrace handler?John Whitington then said:
To quote the documentation for set_uncaught_exception_handler: "If fn raises an exception, it is ignored." This is a bit ambiguous -- it might mean a) The uncaught exception handler you register won't get called from inside itself in the case of an uncaught exception. Nor will any such exceptions be handled by the standard exception handler; or b) Exceptions in the handler literally have no effect. I've done a little test just now, and it seems to be (a), so perhaps it's just in need of clarification in the documentation. (It might be nice to have, for development, an option to have the default exception handler remain active, so it reports any exceptions escaping from the user-installed exception handler).Peter Zotov commented and John Whitington replied:
> Very nice project! However, it looks like the user needs to explicitly > specify the paths to the sources. I have some code to perform a similar Yes, except for '.' which is hardcoded. So, in the simplest case, it works. > task; the paths are actually contained inside the bytecode. > I think that for native-code you can fetch them in a similar way, though > it is a little harder to extract the debug info. > > : https://github.com/whitequark/pry.ml/blob/master/src/pry_bytecode.ml, > see di_paths. Noted. I'd like to add functionality like this. The first thing I'm going to add is automatic finding of the stdlib, since this just requires parsing the output of "ocamlc -config". Unfortunately, I don't believe most OPAM packages install their source, just the .mli files. I wonder how much extra space installing source would take on average, and if people think it's worth it, for this or other reasons.Peter Zotov then said:
> Noted. I'd like to add functionality like this. The first thing I'm > going to add is automatic finding of the stdlib, since this just > requires parsing the output of "ocamlc -config". I would take this directly from OCaml configuration (module Config, -package compiler-libs.common). No shelling out needed.
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00143.htmlPeter Zotov announced:
I'm glad to announce utop 1.16. It will be available in OPAM shortly. Changelog: 1.16 (2014-10-20) ----------------- * make camlp4 support optional * require OCaml 4.01.0 or newer * implement wrapper for -safe-string
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00146.htmlMarek Kubica announced:
I'd like to announce a new release of Slacko, the OCaml Slack API binding. This is both an announcement as well as a request for comments regarding the API. The homepage is at https://github.com/Leonidas-from-XIV/slacko, the documentation can be read online at https://leonidas-from-xiv.github.io/slacko/ and the tarball as well as release notes can be found on https://github.com/Leonidas-from-XIV/slacko/releases/tag/0.10.0. The recommended way is to install it from OPAM of course, which already carries the 0.10.0 release. I've listened to the suggestions by Malcolm, Gabriel and Jaques as well as Drup so the methods are not longer "stringly" typed, each function supports parameters that make more sense, like user/group/channel types, booleans, integers etc. The results are changed from a huge monolithic type to individual polymorphic variants composed of smaller types. But some questions remain: I have a number of types and conversion functions (foo_of_string mostly). These can validate the input (checking if the format is correct or whether the input is not too long) and most likely should. But what is the preferred OCaml way of handling failure to convert? I could use exceptions but that seems kinda type unsafe to me. I could use option types, but that might make for some clunky conversions. Any ideas? Also there are errors like `Msg_too_long. I'm currently exposing them, because the API might throw them. But when doing validation inside my binding, these errors can't really happen, since I validated beforehand. I think that these can be filtered out (since the length limit is static and if it changes, the library can be updated), but if anyone has a different perspective, please speak up. Looking forwards to comments! Oh and I ported from the Camlp4 Lwt macros to PPX. Was super easy and worked like a charm, zero issues.
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00147.htmlThomas Braibant asked:
I am slightly puzzled by a type-error related to first class modules. I am basically defining two types (see full example below) ``` type t = (module A) type 'a s = (module A with type I.t = 'a) ``` and I expect a value of type `'a s` can be coerced to a value of type t. However, this is obviously not the case because I get the following error message, and I wonder why. ``` (* Error: This expression has type a s = (module A with type I.t = a) *) (* but an expression was expected of type t = (module A) *) ``` Is there a common pattern to deal with this situation? Any pointers appreciated. Best, Thomas (* Full example *) module type IN = sig type t val of_string : string -> t val to_string : t -> string end module type A = sig module I : IN val v : string end type t = (module A) type 'a s = (module A with type I.t = 'a) let test1 : t -> string = fun (module T) -> T.v (* let test2 : 'a s -> string = fun (module T) -> T.v The type of this packed module contains variables: 'a s *) let test3 (type a) : a s -> string = fun (module T) -> T.v let test4 (type a) : a s -> string = fun t -> test1 t (* Error: This expression has type a s = (module A with type I.t = a) *) (* but an expression was expected of type t = (module A) *) module A1 : A = struct module I : IN = struct type t = int let of_string = int_of_string let to_string = string_of_int end let v = "A1" end let _ = test1 (module A1) (* OK *) let _ = test3 (module A1) (* OK *)Jeremy Yallop replied:
Conversions between first class module types need explicit coercions. It's sufficient to change your test4 function as follows: > let test4 (type a) : a s -> string = fun t -> test1 t let test4 (type a) : a s -> string = fun t -> test1 (t :> (module A))He later added:
or you can, of course, use the alias 't' to coerce: let test4 (type a) : a s -> string = fun t -> test1 (t :> t)
Archive: https://sympa.inria.fr/sympa/arc/caml-list/2014-10/msg00153.htmlFrançois Pessaux announced:
It is my pleasure to announce (for Damien Doligez ^_^) the release of Zenon, an automatic theorem prover written in OCaml. Zenon handles first-order logic with equality. Its most important feature is that it outputs the proofs of the theorems, in Coq-checkable form. This is version 0.8.0, available at < http://sosie.inria.fr > (and soon at < http://zenon-prover.org >) with several issues fixed since the last release. Unfortunately, there is no documentation yet, so this is for the adventurous spirit. It is released under the New BSD license.
Thanks to Alp Mestan, we now include in the OCaml Weekly News the links to the recent posts from the ocamlcore planet blog at http://planet.ocaml.org/. Tail-recursion: http://shayne-fletcher.blogspot.com/2014/10/tail-recursion.html Haskell : A neat trick for GHCi: http://www.mega-nerd.com/erikd/Blog/CodeHacking/Haskell/ghci-trick.html OCaml 4.02.1 released: http://wodi.forge.ocamlcore.org/2014/10/17/ocaml-4.02.1.html What the interns have wrought: RPC_parallel and Core_profiler: https://blogs.janestreet.com/what-the-interns-have-wrought-rpc_parallel-and-core_profiler/ TEDx Zeroes: http://math.andrej.com/2014/10/16/tedx-zeroes/ OCaml Forge maintenance: https://forge.ocamlcore.org/forum/forum.php?forum_id=912 Binary distribution with 0install: http://ocaml.org/ Functional Software Engineer at Cake Solutions Ltd (Full-time): http://functionaljobs.com/jobs/8755-functional-software-engineer-at-cake-solutions-ltd orgueIREM: https://forge.ocamlcore.org/projects/orgueirem/
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.