Previous week Up Next week


Here is the latest Caml Weekly News, for the week of July 24 to 31, 2012.

  1. Understanding Format
  2. OCaml release 4.00.0
  3. OCaml 4.00.0 installer for Windows
  4. Building Ocaml-4.00 with GODI
  5. utop 1.2
  6. OUD - call for participation
  7. Other Caml News

Understanding Format


Alain Frisch asked and Olivier Andrieu replied:
> I'm trying to understand the semantics of Format boxes, and I need some
> help! Consider the following:
> let () =
> set_margin 500;
> open_vbox 0;
> for _i = 1 to 300 do
> open_hbox ();
> print_string "x";
> close_box ()
> done;
> close_box ()
> Format inserts line breaks, even though the page width (margin) should be
> large enough to contain 300 characters (and there is no break hint anyway).
> Why does it do it? Changing the value passed to set_margin does not seem
> to make a difference (except for small values < 70).

You have to increase the 'max_indent' parameter for the formatter too :

When you open your hbox, you get an implicit break if the current
cursor position is past this max_ident.
Calling set_margin does not change max_indent which keeps its default
value (68).

cf. this comment in :
(* To indent no more than pp_max_indent, if one tries to open a block
beyond pp_max_indent, then the block is rejected on the left
by simulating a break.

OCaml release 4.00.0


Damien Doligez announced:
Dear OCaml users,

I have been rather busy preparing the new OCaml release, and
I had no time to go shopping for a birthday present for my wife.
So... here is a little present for her:

We have the pleasure of celebrating Laïka's birthday by
announcing the release of OCaml version 4.00.0.

This is a major release with many new features, the most
important being generalized algebraic data types (GADTs),
which by themselves justify bumping the major version number.

It is available here:

We also want to thank all the packagers out there who make
this easy to install for end users without recompiling.

Happy birthday,

-- Damien Doligez for the OCaml team.


There are a few changes between 4.00.0+rc1 and 4.00.0:

- PR#5692: regression in 4.00.0+beta2: end locations wrong in camlp4 ast
- PR#5694: crash in type-checker
- PR#5696: ocamldep -native does not print bytecode deps and confuses omake
- [Caml-list] #install_printer gives error in 4.00.0+rc1
- As an unintended consequence of the previous fix, this
release triggers the following warning in ocamlfind:

findlib: [WARNING] Interface topdirs.cmi occurs in several directories:
/usr/local/lib/ocaml, /usr/local/lib/ocaml/compiler-libs

We will fix it in the future, but for the time being you
can safely ignore this particular warning.


OCaml 4.00.0:

(Changes that can break existing programs are marked with a "*")

- The official name of the language is now OCaml.

Language features:
- Added Generalized Abstract Data Types (GADTs) to the language.
See chapter "Language extensions" of the reference manual for documentation.
- It is now possible to omit type annotations when packing and unpacking
first-class modules. The type-checker attempts to infer it from the context.
Using the -principal option guarantees forward compatibility.
- New (module M) and (module M : S) syntax in patterns, for immediate
unpacking of a first-class module.

- Revised simplification of let-alias (PR#5205, PR#5288)
- Better reporting of compiler version mismatch in .cmi files
* Warning 28 is now enabled by default.
- New option -absname to use absolute paths in error messages
- Optimize away compile-time beta-redexes, e.g. (fun x y -> e) a b.
- Added option -bin-annot to dump the AST with type annotations.
- Added lots of new warnings about unused variables, opens, fields,
constructors, etc.
* New meaning for warning 7: it is now triggered when a method is overridden
with the "method" keyword. Use "method!" to avoid the warning.

Native-code compiler:
- Optimized handling of partially-applied functions (PR#5287)
- Small improvements in code generated for array bounds checks (PR#5345,
* New ARM backend (PR#5433):
. Supports both Linux/EABI (armel) and Linux/EABI+VFPv3 (armhf).
. Added support for the Thumb-2 instruction set with average code size
savings of 28%.
. Added support for position-independent code, natdynlink, profiling and
exception backtraces.
- Generation of CFI information, and filename/line number debugging (with -g)
annotations, enabling in particular precise stack backtraces with
the gdb debugger. Currently supported for x86 32-bits and 64-bits only.
- New tool: ocamloptp, the equivalent of ocamlcp for the native-code compiler.

- PR#5645: ocamldoc doesn't handle module/type substitution in signatures
- PR#5544: improve HTML output (less formatting in html code)
- PR#5522: allow refering to record fields and variant constructors
- fix PR#5419 (error message in french)
- fix PR#5535 (no cross ref to class after dump+load)
* Use first class modules for custom generators, to be able to
load various plugins incrementally adding features to the current
* PR#5507: Use Location.t structures for locations.
- fix: do not keep code when not told to keep code.

Standard library:
- Added float functions "hypot" and "copysign" (PR#3806, PR#4752, PR#5246)
* Arg: options with empty doc strings are no longer included in the usage 
- Array: faster implementations of "blit", "copy", "sub", "append" and 
(PR#2395, PR#2787, PR#4591)
* Hashtbl:
. Statistically-better generic hash function based on Murmur 3 (PR#5225)
. Fixed behavior of generic hash function w.r.t. -0.0 and NaN (PR#5222)
. Added optional "random" parameter to Hashtbl.create to randomize
collision patterns and improve security (PR#5572, CVE-2012-0839)
. Added "randomize" function and "R" parameter to OCAMLRUNPARAM
to turn randomization on by default (PR#5572, CVE-2012-0839)
. Added new functorial interface "MakeSeeded" to support randomization
with user-provided seeded hash functions.
. Install new header <caml/hash.h> for C code.
- Filename: on-demand (lazy) initialization of the PRNG used by "temp_file".
- Marshal: marshalling of function values (flag Marshal.Closures) now
also works for functions that come from dynamically-loaded modules (PR#5215)
- Random:
. More random initialization (Random.self_init()), using /dev/urandom
when available (e.g. Linux, FreeBSD, MacOS X, Solaris)
* Faster implementation of Random.float (changes the generated sequences)
- Scanf: new function "unescaped" (PR#3888)
- Set and Map: more efficient implementation of "filter" and "partition"
- String: new function "map" (PR#3888)

Installation procedure:
- Compiler internals are now installed in `ocamlc -where`/compiler-libs.
The files available there include the .cmi interfaces for all compiler
modules, plus the following libraries:
ocamlcommon.cma/.cmxa modules common to ocamlc, ocamlopt, ocaml
ocamlbytecomp.cma/.cmxa modules for ocamlc and ocaml
ocamloptcomp.cma/.cmxa modules specific to ocamlopt
ocamltoplevel.cma modules specific to ocaml
(PR#1804, PR#4653, frequently-asked feature).
* Some .cmi for toplevel internals that used to be installed in
`ocamlc -where` are now to be found in `ocamlc -where`/compiler-libs.
Add "-I +compiler-libs" where needed.
* toplevellib.cma is no longer installed because subsumed by
ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma
- Added a configuration option (-with-debug-runtime) to compile and install
a debug version of the runtime system, and a compiler option
(-runtime-variant) to select the debug runtime.

Bug Fixes:
- PR#1643: functions of the Lazy module whose named started with 'lazy_' have
been deprecated, and new ones without the prefix added
- PR#3571: in Bigarrays, call msync() before unmapping to commit changes
- PR#4292: various documentation problems
- PR#4511, PR#4838: local modules remove polymorphism
* PR#4549: Filename.dirname is not handling multiple / on Unix
- PR#4688: (Windows) special floating-point values aren't converted to strings
- PR#4697: Unix.putenv leaks memory on failure
- PR#4705: camlp4 does not allow to define types with `True or `False
- PR#4746: wrong detection of stack overflows in native code under Linux
- PR#4869: rare collisions between assembly labels for code and data
- PR#4880: "assert" constructs now show up in the exception stack backtrace
- PR#4892: Array.set could raise "out of bounds" before evaluating 3rd arg
- PR#4937: camlp4 incorrectly handles optional arguments if 'option' is
- PR#5024: camlp4r now handles underscores in irrefutable pattern matching of
- PR#5064, PR#5485: try to ensure that 4K words of stack are available
before calling into C functions, raising a Stack_overflow exception
otherwise. This reduces (but does not eliminate) the risk of
segmentation faults due to stack overflow in C code
- PR#5073: wrong location for 'Unbound record field label' error
- PR#5084: sub-sub-module building fails for native code compilation
- PR#5120: fix the output function of Camlp4.Debug.formatter
- PR#5131: compilation of custom runtime with g++ generates lots of warnings
- PR#5137: caml-types-explore does not work
- PR#5159: better documentation of type Lexing.position
- PR#5171: Map.join does more comparisons than needed
- PR#5176: emacs mode: stack overflow in regexp matcher
- PR#5179: port OCaml to mingw-w64
- PR#5211: updated Genlex documentation to state that camlp4 is mandatory for
'parser' keyword and associated notation
- PR#5214: ocamlfind plugin invokes 'cut' utility
- PR#5218: use $(MAKE) instead of "make" in Makefiles
- PR#5224: confusing error message in non-regular type definition
- PR#5231: camlp4: fix parsing of <:str_item< type t = $x$ >>
- PR#5233: finaliser on weak array gives dangling pointers (crash)
- PR#5238, PR#5277: Sys_error when getting error location
- PR#5261, PR#5497: Ocaml source-code examples are not "copy-paste-able"
* PR#5279: executable name is not initialized properly in caml_startup_code
- PR#5290: added hash functions for channels, nats, mutexes, conditions
- PR#5295: OS threads: problem with caml_c_thread_unregister()
- PR#5301: camlp4r and exception equal to another one with parameters
- PR#5305: prevent ocamlbuild from complaining about links to _build/
- PR#5306: comparing to Thread.self() raises exception at runtime
- PR#5309: Queue.add is not thread/signal safe
- PR#5310: Ratio.create_ratio/create_normalized_ratio have misleading names
- PR#5311: better message for warning 23
* PR#5312: command-line arguments @reponsefile auto-expansion feature
removed from the Windows OCaml runtime, to avoid conflicts with "-w @..."
- PR#5313: ocamlopt -g misses optimizations
- PR#5316: objinfo now shows ccopts/ccobjs/force_link when applicable
- PR#5318: segfault on stack overflow when reading marshaled data
- PR#5319: %r11 clobbered by Lswitch in Windows AMD64 native-code compilation
- PR#5322: type abbreviations expanding to a universal type variable
- PR#5325: (Windows) blocked Unix.recv in one thread blocks Unix.send in
another thread
- PR#5328: under Windows, leaves sockets in non-blocking mode
- PR#5330: thread tag with '.top' and '.inferred.mli' targets
- PR#5331: ocamlmktop is not always a shell script
- PR#5335: Unix.environment segfaults after a call to clearenv
- PR#5338: has windows style end-of-lines (mingw)
- PR#5343: ocaml -rectypes is unsound wrt module subtyping
- PR#5344: some predefined exceptions need special printing
- PR#5349: Hashtbl.replace uses new key instead of reusing old key
- PR#5356: ocamlbuild handling of 'predicates' for ocamlfind
- PR#5364: wrong compilation of "((val m : SIG1) : SIG2)"
- PR#5370: ocamldep omits filename in syntax error message
- PR#5374: camlp4 creates wrong location for type definitions
- PR#5380: strange sscanf input segfault
- PR#5382: EOPNOTSUPP and ENOTSUPP different on exotic platforms
- PR#5383: build failure in Win32/MSVC
- PR#5387: camlp4: str_item and other syntactic elements with Nils are
not very usable
- PR#5389: compaction sometimes leaves a very large heap
- PR#5393: fails to build from source on GNU/kFreeBSD because of -R link 
- PR#5394: documentation for -dtypes is missing in manpage
- PR#5397: Filename.temp_dir_name should be mutable
- PR#5410: fix printing of class application with Camlp4
- PR#5416: (Windows) Unix.(set|clear)_close_on_exec now preserves blocking 
- PR#5435: ocamlbuild does not find .opt executables on Windows
- PR#5436: update object ids on unmarshaling
- PR#5442: camlp4: quotation issue with strings
- PR#5453: configure doesn't find X11 under Ubuntu/MultiarchSpec
- PR#5461: Double linking of bytecode modules
- PR#5463: Bigarray.*.map_file fail if empty array is requested
- PR#5465: increase stack size of ocamlopt.opt for windows
- PR#5469: private record type generated by functor loses abbreviation
- PR#5475: Wrapper script for interpreted LablTk wrongly handles command line
- PR#5476: bug in native code compilation of let rec on float arrays
- PR#5477: use pkg-config to configure graphics on linux
- PR#5481: update camlp4 magic numbers
- PR#5482: remove bashism in test suite scripts
- PR#5495: camlp4o dies on infix definition (or)
- PR#5498: Unification with an empty object only checks the absence of
the first method
- PR#5503: error when ocamlbuild is passed an absolute path as build directory
- PR#5509: misclassification of statically-allocated empty array that
falls exactly at beginning of an otherwise unused data page.
- PR#5510: ocamldep has duplicate -ml{,i}-synonym options
- PR#5511: in Bigarray.reshape, unwarranted limitation on new array 
- PR#5513: Int64.div causes floating point exception (ocamlopt, x86)
- PR#5516: in Bigarray C stubs, use C99 flexible array types if possible
- PR#5518: segfault with lazy empty array
- PR#5531: Allow ocamlbuild to add ocamldoc flags through -docflag
and -docflags switches
- PR#5543: in Bigarray.map_file, try to avoid using lseek() when growing file
- PR#5538: combining -i and -annot in ocamlc
- PR#5648: (probably fixed) test failures in tests/lib-threads
- PR#5551: repeated calls to find_in_path degrade performance
- PR#5552: Mac OS X: unrecognized gcc option "-no-cpp-precomp"
- PR#5555: add Hashtbl.reset to resize the bucket table to its initial size
- PR#5560: incompatible type for tuple pattern with -principal
- PR#5575: Random states are not marshallable across architectures
- PR#5579: camlp4: when a plugin is loaded in the toplevel,
Token.Filter.define_filter has no effect before the first syntax error
- PR#5585: typo: "explicitely"
- PR#5587: documentation: "allows to" is not correct English
- PR#5593: remove C file when -output-obj fails
- PR#5597: register names for instrtrace primitives in embedded bytecode
- PR#5598: add backslash-space support in strings in ocamllex
- PR#5603: wrong .file debug info generated by ocamlopt -g
- PR#5604: fix permissions of files created by ocamlbuild itself
- PR#5610: new unmarshaler (from PR#5318) fails to freshen object identifiers
- PR#5614: add missing -linkall flag when compiling ocamldoc.opt
- PR#5616: move ocamlbuild documentation to the reference manual
- PR#5619: Uncaught CType.Unify exception in the compiler
- PR#5620: invalid printing of type manifest (camlp4 revised syntax)
- PR#5637: invalid printing of anonymous type parameters (camlp4 revised 
- PR#5643: issues with .cfi and .loc directives generated by ocamlopt -g
- PR#5644: Stream.count broken when used with Sapp or Slazy nodes
- PR#5647: Cannot use install_printer in debugger
- PR#5651: printer for abstract data type (camlp4 revised syntax)
- PR#5654: self pattern variable location tweak
- PR#5655: ocamlbuild doesn't pass cflags when building C stubs
- PR#5657: wrong error location for abbreviated record fields
- PR#5659: ocamlmklib -L option breaks with MSVC
- PR#5661: fixes for the test suite
- PR#5668: Camlp4 produces invalid syntax for "let _ = ..."
- PR#5671: initialization of compare_ext field in 
- PR#5677: do not use "value" as identifier (
- PR#5687: dynlink broken when used from "output-obj" main program (bytecode)
- problem with printing of string literals in camlp4 (reported on caml-list)
- emacs mode: colorization of comments and strings now works correctly
- problem with forall and method (reported on caml-list on 2011-07-26)
- crash when using OCAMLRUNPARAM=a=X with invalid X (reported in private)

Feature wishes:
- PR#352: new option "-stdin" to make ocaml read stdin as a script
- PR#1164: better error message when mixing -a and .cmxa
- PR#1284: documentation: remove restriction on mixed streams
- PR#1496: allow configuring LIBDIR, BINDIR, and MANDIR relative to $(PREFIX)
- PR#1835: add Digest.from_hex
- PR#1898: toplevel: add option to suppress continuation prompts
- PR#4278: configure: option to disable "graph" library
- PR#4444: new String.trim function, removing leading and trailing whistespace
- PR#4549: make Filename.dirname/basename POSIX compliant
- PR#4830: add option -v to
- PR#4898: new Sys.big_endian boolean for machine endianness
- PR#4963, PR#5467: no extern "C" into ocaml C-stub headers
- PR#5199: tests are run only for bytecode if either native support is 
or a non-empty value is set to "BYTECODE_ONLY" Makefile variable
- PR#5215: marshalling of dynlinked closure
- PR#5236: new '%revapply' primitive with the semantics 'revapply x f = f x',
and '%apply' with semantics 'apply f x = f x'.
- PR#5255: natdynlink detection on powerpc, hurd, sparc
- PR#5295: OS threads: problem with caml_c_thread_unregister()
- PR#5297: compiler now checks existence of builtin primitives
- PR#5329: (Windows) more efficient if all fd's are sockets
- PR#5357: warning for useless open statements
- PR#5358: first class modules don't allow "with type" declarations for types
in sub-modules
- PR#5385: configure: emit a warning when MACOSX_DEPLOYMENT_TARGET is set
- PR#5396: ocamldep: add options -sort, -all, and -one-line
- PR#5397: Filename.temp_dir_name should be mutable
- PR#5403: give better error message when emacs is not found in PATH
- PR#5411: new directive for the toplevel: #load_rec
- PR#5420: Unix.openfile share mode (Windows)
- PR#5421: Unix: do not leak fds in various open_proc* functions
- PR#5434: implement Unix.times in win32unix (partially)
- PR#5438: new warnings for unused declarations
- PR#5439: upgrade config.guess and config.sub
- PR#5445 and others: better printing of types with user-provided names
- PR#5454: is missing and md5 doc update
- PR#5455: .emacs instructions, add lines to recognize ocaml scripts
- PR#5456: pa_macro: replace __LOCATION__ after macro expansion; add 
- PR#5461: bytecode: emit warning when linking two modules with the same name
- PR#5478: ocamlopt assumes ar command exists
- PR#5479: Num.num_of_string may raise an exception, not reflected in the
- PR#5501: increase IO_BUFFER_SIZE to 64KiB
- PR#5532: improve error message when bytecode file is wrong
- PR#5555: add function Hashtbl.reset to resize the bucket table to
its initial size.
- PR#5586: increase UNIX_BUFFER_SIZE to 64KiB
- PR#5597: register names for instrtrace primitives in embedded bytecode
- PR#5599: Add warn() tag in ocamlbuild to control -w compiler switch
- PR#5628: add #remove_directory and Topdirs.remove_directory to remove
a directory from the load path
- PR#5636: in system threads library, issue with linking of pthread_atfork
- PR#5666: C includes don't provide a revision number
- ocamldebug: ability to inspect values that contain code pointers
- ocamldebug: new 'environment' directive to set environment variables
for debuggee
- configure: add -no-camlp4 option

Shedding weight:
* Removed the obsolete native-code generators for Alpha, HPPA, IA64 and MIPS.
* The "DBM" library (interface with Unix DBM key-value stores) is no
longer part of this distribution. It now lives its own life at
* The "OCamlWin" toplevel user interface for MS Windows is no longer
part of this distribution. It now lives its own life at

Other changes:
- Copy VERSION file to library directory when installing.
Richard Jones then said:
OCaml 4.00.0 is now in Fedora 18.

We were chasing a very odd and very rare OCaml heap corruption bug in
32 bit i686 binaries build by OCaml 4.00.0 beta 2 which caused
segfaults in programs like ocamlopt.opt and coq:

I haven't yet tested OCaml 4.00.0 non-beta, but will be doing so next
week. It might be fixed.

Do the symptoms ring any bells?
Later on, Richard Jones added:
In fact, no it's not fixed in OCaml 4.00.0 official release.

OCaml 4.00.0 installer for Windows


Jonathan Protzenko announced:
Following Damien's announcement, the installer for windows has been
updated, and is now available at

This installer will:
- install OCaml, findlib and flexdll
- (optional) install Emacs with the caml-mode set up and the right
  file associations in the Windows explorer,
- (optional) install ActiveTCL so that OCamlBrowser and labltk can
  work properly
- (optional, required for native compilation) launch the cygwin setup
  with the right packages pre-configured so that you have a working
  OCaml development environment, where you can run find, make, as,
  ocamlbuild, and the like.

This installer does not feature any package management system.
However, it should work with odb Odb
successfully installed lwt on my test machine, as well as easy-format,
and a few other libraries from Jane Street.

The installer is generated using NSIS, and the NSIS script file may
contains bugs. If you find any, please submit a patch using the GitHub

Building Ocaml-4.00 with GODI


Gerd Stolpmann announced:
I've just released a package for OCaml-4.00. Note that this is still
experimental, and not every package can be installed yet. But the most
important things have already been fixed.

Please use this bootstrap:

The default here is still 3.12, so please change it to 4.00 when you
are prompted for the OCaml version. To install, just unpack this
archive, and run


I ran tests on Linux, OS X, Win32 (32 bit only, with mingw64),
OpenSolaris, and FreeBSD. Win32 is a bit more complicated, as you need
Cygwin with the _right_ packages. The easiest way is to use Sébastien
Fricker's installer on (GODISetup.exe).

There is still a lot to do until the same quality is reached as for
3.12. If you like to help, you are very welcome - just sign up to the
GODI mailing list, and send a message:

More information on GODI is available here:

utop 1.2


Jérémie Dimino announced:
The utop team is happy to announce the release of utop 1.2, an
improved toplevel for OCaml. You can download it at this url:

Important changes are:

* utop now handles parsing/typing/compilation errors itself, this
means a better highlighting and more importantly that errors are
emphasized in the emacs mode. The style of errors can be controlled
via the face "utop-error" in emacs and with the "error" resource of
~/.utoprc in the terminal.

* a "" is automatically inserted for toplevel expressions
of type "_ Lwt.t". For example, with the classic toplevel:

# Lwt_io.printf "Hello, world!\n";;
- : unit Lwt.t = <abstract>

and with the new utop:

# Lwt_io.printf "Hello, world!\n";;
- : unit = ()

This behavior can be disabled with "UTop.set_auto_run_lwt false".

* many emacs mode fixes and improvements. It is now possible to
complete a phrase in a tuareg/typerex buffer using the toplevel
environment. You have to bind the function "utop-edit-complete" to a
key for this feature to work, it is unbound by default.

Here is the complete changelog:

* ocaml 4.00 compatibility
* prevent findlib from being initialized twice
* better highlighting of errors
* automatically insert for
toplevel expressions of type 'a Lwt.t
* better camlp4 support
** parse quotations and antiquotations to
handle completion inside them
** better support revised syntax
* emacs mode improvements
** various fixes
** highlight errors
** add a menu
** add interactive list of findlib packages
** packages can be pre-loaded via the file variable
** better tuareg integration
** typerex integration
** allow to complete using the toplevel environment
in a tuareg buffer
** allow to change the utop command
** use the same history as the terminal mode
** follow output of ocaml

OUD - call for participation


Anil Madhavapeddy continued this old thread, to add:
We have now updated the OUD website with the abstracts of all the 

As a reminder, early registration is on August 9th, so be sure to
register soon. All of the student applications will receive a
response shortly, so thank you for all the applications.

There is a lot going on during the week of ICFP in addition to the
OCaml workshop, and you might want to also attend some of the other
events that are co-located (including the ML workshop the day before).
I have written an overview of the week here:

We had a lot of fun last year in Japan, and I hope to see you all
in Copenhagen in September for an equally memorable get-together!
Feel free to contact myself or Didier with any queries.

Other Caml News

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

Why you should go to ICFP 2012:

OCaml 4.00.0 released:



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