Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of August 09 to 23, 2011.

  1. Piqi-0.5.6 released
  2. cppo 0.9.2 - cpp for OCaml
  3. Bolt 1.2 release
  4. Texexpand (and related tools) in OCaml
  5. llpp v7
  6. New release of the Caml Examples collection
  7. Parmap
  8. Zarith
  9. packing modules as a functor
  10. OpenGL ES for iPhone Simulator; working example app
  11. Other Caml News

Piqi-0.5.6 released

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00087.html

Anton Lavrik announced:
It is my pleasure to announce the new Piqi-0.5.6 release.

Piqi is a data serialization system for OCaml and Erlang. Starting
from this release, it supports 4 serialization formats: Google
Protocol Buffers, JSON, XML and Piq.

Some other new features include:

* An option to use OCaml arrays instead of lists for representing Piqi
lists and repeated fields.

* The ability to serialize arbitrary monomorphic OCaml types by
mapping them to already supported or defined Piqi types. This
mechanism can be used, for example, for serializing OCaml chars as
integers, bigints as decimal strings, or even "string
Map.Make(String).t" as list of {key, value} records.

* Support for “packed” binary encoding for primitive numeric types.
This is a compact encoding for representing repeated int, float or
bool values in Protocol Buffers.

* Windows builds using either Cygwin or MinGW.

Official announcement (it also includes links to examples):
http://piqi.org/blog/2011/08/11/piqi-0-5-6-released/
Full changelog: https://github.com/alavrik/piqi/blob/master/CHANGES
Downloads: http://piqi.org/downloads/

Your comments, suggestions and participation are welcome!
      

cppo 0.9.2 - cpp for OCaml

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00088.html

Martin Jambon announced:
I would like to announce the release of cppo 0.9.2 which contains a few
additional features since the last announcement in 2009.

  http://martin.jambon.free.fr/cppo.html

cppo is a lightweight preprocessor analogous to cpp and compatible with
the OCaml syntax. It provides the classic directives #define, #include,
#ifdef, etc.

Documentation: http://martin.jambon.free.fr/cppo-manual-0.9.2.txt


New features:

1. #ext directive: calling external preprocessors
2. STRINGIFY and CONCAT


1. #ext directive: calling external preprocessors
=================================================

The new #ext directive allows to call an external command to process a
lines of input until #endext.

$ cat example1.ml
let msg =
#ext rot13
  "BPnzy ehyrf!"
#endext

let () = print_endline msg

$ ocamlopt -o example1 \
  -pp "cppo -x rot13:\"tr '[a-zA-Z]' '[n-za-mN-ZA-M]'\"" example1.ml

$ ./example1
OCaml rules!


2. STRINGIFY and CONCAT
=======================

STRINGIFY allows to build string literals from unquoted text. This is
useful for including source code in error messages. STRINGIFY(foo) is
the equivalent of #foo in cpp syntax.

CONCAT concatenates its two arguments into a single identifier.
CONCAT(a, b) is the equivalent of a ## b in cpp syntax.
      

Bolt 1.2 release

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00119.html

Xavier Clerc announced:
This post announces the 1.2 release of the Bolt project, whose goal is
to provide a comprehensive yet flexible logging framework for the
Objective Caml language.

Home page: http://bolt.x9c.fr

Main changes since 1.1:
  - update for Objective Caml 3.12.1
  - support for Daikon layout
  - enhanced support for Paje layout
  - file rotation can now be requested on signal reception (SIGHUP,
    SIGUSR1, or SIGUSR2) using the 'signal' key in the configuration file
  - syntax extension: possibility to use an identifier as the 'LOG' message
  - syntax extension: 'WITH' and 'EXN' as synonyms for respectively
    'PROPERTIES' and 'EXCEPTION'
  - some code factorization
      

Texexpand (and related tools) in OCaml

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00120.html

Roberto Di Cosmo announced:
        here is an OCaml rewriting of some useful LaTeX utilities: 
texexpand and texdepend.

This code was written in 2003, so it does not uses all of the latest
bells and whistles in our favourite programming language, but it is
already quite cleaner than the original C code, and comes with some
added goodies:

 - the -b option allows to include the .bbl file in your expanded
   output, which is useful for final version of papers for ACM, etc.

 - the -x option adds some extra information to the expanded file,
   that allows to "unexpand" the .tex file with the companion 
   texunexpand tool (in Perl, sigh...)

Project home: https://gitorious.org/texexpand-ocaml

To compile and install:

 git clone git://gitorious.org/texexpand-ocaml/texexpand-ocaml.git
 make 
 make install
      

llpp v7

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00121.html

malc announced:
New version of llpp is now available (tagged v7) at
http://repo.or.cz/w/llpp.git

Blurb:

llpp a graphical PDF viewer which aims to superficially resemble
less(1)

Changes (relative to v5):

* Human readable/editable configuration file
* Optional (default on) proportional display (for documents with variable
  width pages)
* Better pixmap cache
* Bird's eye (aka thumbnail) mode
* Help and info/setup modes (accessible by pressing 'h' and 'i' respectively)
* UI font handling was redone, i.e. Glut bitmap character API was
  replaced with Tor Andersson's glfont

  Rationale
   * bitmap characters are very very slow
   * the coverage of builtin fixed/helvetica/courier/times is tiny, so
     that not even cyrillic is visible in outlines
   * bitmaps live in their special raster world in OpenGL
   * bitmaps can not be made antialiased (glfont can be made aliased
     should there be a need)

* Tweaks all over the place (autoscrolling/zooming/user defined knobs/etc)

This version is known to work on Linux(ppc/x86_64), FreeBSD (Juergen
Lock), Mac OS X(x86_64). It used to work on Mac OS X/ppc[32|64] and
Windows XP(i386)/Vista (x86_64) in the past, but wasn't tested there
in a while.

OS X and Windows are second class citizens though.

Build instructions:
http://repo.or.cz/w/llpp.git/blob/v7:/BUILDING

[1] https://github.com/ccxvii/snippets/blob/master/glfont.c
      

New release of the Caml Examples collection

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00134.html

Pierre Weis announced:
The Caml Examples package is a large set of Caml example programs.
Most of the programs are provided both in Objective Caml and in Caml Light.

This new enhanced version of the Caml Examples package contains the complete
set of examples from the book ``Le langage Caml'' in Objective Caml (and
obviously also in Caml Light).

You will also find numerous examples of GUI programs, in addition to a
collection of games such as ``Le solitaire'', ``Sudoku'', ``Hanoi'',
``Showsort'', ``KB'' ...

The package home page is at http://cristal.inria.fr/caml_examples/eng.html

The tar balls are available here:

http://cristal.inria.fr/caml_examples/ocaml-examples-3.12.tar.gz
http://cristal.inria.fr/caml_examples/camllight-examples-0.81.tar.gz

All constructive criticisms and propositions are warmly welcomed.
      

Parmap

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00156.html

Roberto Di Cosmo announced:
Dear all,
       a few lines to announce the availability of a minimalistic library 
which
can be useful to exploit your multicore processor with minimal modifications 
to
your OCaml programs.

In a nutshell
-------------

If you want to use your many cores to accelerate an operation which happens to
be a map, fold or map/fold (map-reduce), just use Parmap's parmap, parfold and
parmapfold primitives in place of the standard List.map and friends, and 
specify
the number of subprocesses to use by the optional parameter ncores.

For example, in the classical Mandelbrot example present in the example 
directory,
the line 

        Parmap.parmap pixel tasks ~ncores:i

allows to spawn i separate processes, each working on 1/ith of the list tasks.

Rationale
---------

The principle of Parmap is very simple: when you call one of the three 
available
primitives, map, fold, and  mapfold , your OCaml  sequential program forks  
in n
subprocesses (you choose the n), and each subprocess performs the computation 
on
the  1/n of the data, returing  the results through a  shared memory area to 
the
parent process, that resumes  execution once all  the children  have 
terminated,
and the data has been recollected.

This means that you *must* run your program on a *single* multicore machine.
Repeat after us: Parmap is not meant to run on a cluster, see one of the many
available (re)implementations of the map-reduce schema for that.

By forking the parent process  on a sigle  machine, the children get access, 
for
free, to all the data structures already built, even the imperative ones, and 
as
far as your computation  inside the map/fold  does not produce side effects 
that
need  to be  preserved, the  final result will   be the same  as  performing 
the
sequential operation, the only difference is that you might get it faster.

Of course, if you happen  to have open  channels, or files, or other 
connections
that should only be  used by the parent  process, your program  may behave in 
 a
very wierd way: as an example, *do  not* open a  graphic window before 
calling a
Parmap primitive, and   *do   not*  use  this  library   if  your  program    
is
multi-threaded!

The OCaml code is quite simple and does not rely on any  external C library: 
all
the magic is done by your operating system's fork and memory mapping 
mechanisms.
One could gain some speed by implementing a marshal/unmarshal operation 
directly
on bigarrays, but we did not do this yet.


How to get it
-------------

Project home: https://gitorious.org/parmap

To compile and install:

 git clone git://gitorious.org/parmap/parmap.git
 make
 make install

Enjoy

-- Marco Danelutto and Roberto Di Cosmo

P.S.: special thanks to Pierre Chambart for useful discussions on this code
      

Zarith

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00158.html

Xavier Leroy announced:
It is my pleasure to announce release 1.0 of Zarith, a new OCaml
library for exact, arbitrary-precision arithmetic on integers and
rationals.  Zarith was written by Antoine Miné with a little help from
me and feedback from Pascal Cuoq.

To download:  http://forge.ocamlcore.org/projects/zarith/

The implementation uses GMP (the GNU Multiple Precision arithmetic
library) to compute over big integers.  However, small integers are
represented as unboxed Caml integers, to save space and improve
performance. Big integers are allocated in the Caml heap, bypassing
GMP's memory management and achieving better GC behavior than e.g.
the MLGMP library.  Computations on small integers use a special,
faster path (coded in assembly for some platforms and functions)
eschewing calls to GMP, while computations on large intergers use the
low-level MPN functions from GMP.  As a consequence, Zarith is much
faster and more space-efficient than the Big_int module from OCaml's
standard distribution.

Additional niceties of Zarith include:
- short function names and infix operators, allowing one to write e.g.
    Z.(~$2 + ~$5 * x)
- polymorphic comparisons (=, <, >, etc) work correctly on Zarith's
  big integers, provided OCaml 3.12.1 or later is used.

Feedback is welcome, preferably through the bug tracker at
http://forge.ocamlcore.org/projects/zarith/
      
rixed asked and Gerd Stolpmann replied:
> Is there anything special in 3.12.1 to help library authors define
> specialized comparison operators ?

You can define such operators for abstract values only (i.e. on the C
side of bindings), and this is available for a long time. There is no
such feature for data structures entirely programmed in OCaml (which is
a bit self-discriminating, IMHO).

I guess the problem is that any addition of comparison operators
requires another level of indirection, and it would feel strange to
program and use. This means one could imagine with minimal modifications
of the current runtime to support something like

type 'a wrapped_value
val wrap_value : 'a comparison_operators -> 'a -> 'a wrapped_value
val unwrap_value : 'a wrapped_value -> 'a

In the machine representation, a wrapped_value would have a special tag
to signal the runtime that it carries comparison operators. Because of
this indirection, it is inconvenient to use, as the programmer of a data
structure would need to wrap and unwrap values just to override the
comparisons (basically like it is possible in C today). One idea to
improve this could be a special kind of functor that is able to add
wrap/unwrap calls to a given argument module, so the programmer would
not have to program this explicitly.
      
Gabriel Scherer also replied:
Yes, from the 3.12.1 changelog:
> - Added new operation 'compare_ext' to custom blocks, called when
>  comparing a custom block value with an unboxed integer.

The  following fix is also possibly relevant:
> - Hardened generic comparison in the case where two custom blocks
>  are compared and have different sets of custom operations.

I believe the comparison hardening was made desirable by the expected
use of first-class modules to encode existential datatypes: with
existential datatypes you may try to use the polymorphic comparison
operators on two values of the same (existential) datatype having
different internal representations. The problem didn't happen with the
previous encoding of existential types using first-class polymorphism,
as it implies packing the value inside closures, so the polymorphic
comparison operators were not usable.
      
Alain Frisch then added:
The problem existed before, because of exceptions. When two exception
values having constructors with the same name are compared with the
polymorphic equality, their arguments are compared structurally even
if they don't have the same type. (One way to address this would be to
have a special tag on exception values to force physical comparison of
the constructors.)
      

packing modules as a functor

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00175.html

Fabrice Le Fessant announced:
  We have recently worked on the OCaml compiler to allow packing
compilation units inside a functor. This work extends the current -pack
option with a new -pack-functor option, that will generate a compilation
unit, containing a functor composed of independent compilation units
(compiled with a new -functor option).

  As we are looking for feedback on the utility of this feature, we have
written a small page to release the patch and describe how to use it:

http://www.ocamlpro.com/code/2011-08-10-ocaml-pack-functors.html

  There are also two additional features in the patch: (1) you can use
-i on interface files (.cmi) instead of only sources, and (2) you can
use -pack to generate an interface file (.cmi) from other interface files.

  The page has also a link to "ocp-pack", a simple program to pack
sources instead of compilation units, to achieve the same result as the
-pack and -pack-functor options. Note that, if you have recursive
dependencies between compilation units (usually achieved by hidden
dependencies between abstract types), you will need a patched OCaml to
be able to compile the new source (the patch is also provided).
      

OpenGL ES for iPhone Simulator; working example app

Archive: https://sympa-roc.inria.fr/wws/arc/caml-list/2011-08/msg00177.html

Jeffrey Scofield announced:
A while back I modified LablGL to work with OpenGL ES 1.1, calling my
modified version LablGLES.  Just recently I got LablGLES working in the
iPhone Simulator, which I've found to be a nice prototyping environment
for iOS projects.

I also made an example LablGLES app that works on both the iPhone
Simulator and the iPhone itself.  It's called IcosaBlue, since it
displays a rotating blue icosahedron.  It's very simple, but it's a
complete example of an OpenGL ES iPhone app coded in OCaml.

For those interested in trying OpenGL ES on iPhone and the iPhone
Simulator, I've released sources and binaries for everything.  Here are
some links:

  [LablGLES, OpenGL ES for iPhone and iPhone Simulator][1]
  [IcosaBlue, rotating blue icosahedron using LablGLES][2]
  [General page of OCaml-on-iOS resources][3]
  [Home of LablGL, OCaml OpenGL interface by Jacques Garrigue][4]
  
[1]: http://psellos.com/ocaml/lablgles-build.html
[2]: http://psellos.com/ocaml/example-app-icosablue.html
[3]: http://psellos.com/ocaml/
[4]: http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgl.html

I'd be happy to hear from anybody interested in OCaml on iOS.
      

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 http://planet.ocamlcore.org/.

Putting it all together: PubSub for OCaml with Coherence:
  http://gaiustech.wordpress.com/2011/08/22/putting-it-all-together-pubsub-for-ocaml-with-coherence/

Zarith 1.0 released:
  https://forge.ocamlcore.org/forum/forum.php?forum_id=804

Coq Programming with Subsets:
  http://seb.mondet.org/blog/post/coqtests-01-subsets.html

ocaml sqlite3 date:
  http://www.rktmb.org/post/2011/08/17/ocaml-sqlite3-date

more on precise date on ocaml:
  http://www.rktmb.org/post/2011/08/17/more-on-precise-date-on-ocaml

Queries in Coherence with OCaml:
  http://gaiustech.wordpress.com/2011/08/16/queries-in-coherence-with-ocaml/

Bolt: 1.2:
  https://forge.ocamlcore.org/forum/forum.php?forum_id=803
      

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