Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of December 20 to 27, 2011.

  1. Barista 2.0-alpha2
  2. Format OCaml Code
  3. try ocaml website
  4. Need help for a practical hacking book about ocaml
  5. RFC: basename, dirname, PR#4549
  6. Other Caml News

Barista 2.0-alpha2

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

Xavier Clerc announced:
This post announces the 2.0-alpha2 release of the Barista project, whose goal 
is to provide
a library for Java class file construction and a Java [dis]assembler, 
released under the LGPLv3.

Home page: http://barista.x9c.fr
Forge page: https://forge.ocamlcore.org/projects/barista/

Main changes since 2.0-alpha:
  - move from Java 1.6 to Java 1.7 as default version
  - syntax extension for 'exception pattern' (BARISTA_ERROR)
  - syntax extension for Unicode literals (@"string" and @'c')
  - InputStream.t and OutputStream.t can now be created from functions
  - better error reporting when a signature is invalid
  - helper functions for serialization
  - minor refactoring of code (with small impact on API)
  - removed dependency to 'Str' module
  - bug #73: uniform handling of depencies
  - bug #83: correct construction of constant pool w.r.t. LDC instructions
      

Format OCaml Code

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

Haihao Shen asked, Mihamina Rakotomandimby replied, and Gabriel Scherer then said:
>> Does anyone know whether there is some tools or scripts to format ocaml
>> code in a unified format?
>
>
> If you mean having a "good" indentation, opening it in Emacs+tuareg-mode
> then indenting will work fine.
>
> Note that it's a file by file way and it doesn not split uselessly long
> lines to shorter ones: just indentation. Or I dont know how to fully use
> tuareg-mode ;-).
>
> For a large set of files, I don't know how to ease the work.

Camlp4 parses Ocaml source, and can reprint it. You can't customize
the output much, it's defined by the pretty-printer (but you could
write your own pretty-printer), and it probably doesn't correspond to
your own OCaml style. If you're only looking for a way to normalize
indentation, you may be happy with that.

  camlp4o file.ml (* outputs in the console *)
  camlp4o file.ml -o output.ml

Note that piping/redirection `camlp4o file.ml > foo` doesn't work as
camlp4o sends a marshalled AST by default.
An issue with camlp4 is that it can sometimes move comments a bit: the
placement of comments in the reformatted source is approximative *with
respect to whitespace* (you sometimes have a blank inserted between a
phrase and the comment). That is not really an issue for the human
reader, but it tends to confuse `ocamldoc`, which relies on whitespace
heuristics to know which phrase a comment documents. You should think
twice if you wish to use both camlp4 and ocamldoc at the same time.

If you wanted to write your own pretty-printer (as a Camlp4 printer,
or based on your own or another parser), you could be interested in:
- The [Pprint] module of François Pottier, an interesting adaptation
of Daan Leijen's Haskell PPrint library
   http://pauillac.inria.fr/~fpottier/
- The [easy-format] library of Martin Jambon
   http://martin.jambon.free.fr/easy-format.html
- The [Format] module of the standard library
   http://caml.inria.fr/resources/doc/guides/format.en.html

I have only used Format and Pprint, and prefer Pprint (simpler to
understand and use).
      
rixed then said and Jérémie Dimino replied:
> > Note that piping/redirection `camlp4o file.ml > foo` doesn't work as
> > camlp4o sends a marshalled AST by default.
> 
> This is indeed annoying.
> Unfortunately, and quite surprisingly to me, using -o /dev/stdout does
> not help.

You can force camlp4 to use the pretty-printer with:

  camlp4o -printer o file.ml > foo
      
Jun Furuse replied to the original post:
ocaml-indent may help you, at least around indentations:
 https://bitbucket.org/camlspotter/ocaml-indent/wiki/Home
      

try ocaml website

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

Fabrice Le Fessant announced:
  We worked hard on our "Try OCaml" website, started by Çagdas, and we
managed to improve it enough, so that we think people can start using it
(and hopefully, improving it).

It is available here:

http://try.ocamlpro.com/

  There are 3 lessons, two lessons for "getting a taste of OCaml"
(totalling 10 steps), and the last one about some new features in 3.12.
You can use the "lessons()" command in the toplevel to get the current
list of lessons (in case we contribute more in the meantime !).

  We welcome any comment to improve it, bug reports, and new content.
The repository is on Github:

https://github.com/OCamlPro/tryocaml

  You can easily fork it, compile it, modify it, and send us pull
requests if you want your content published on our site.

We will probably continue to focus on the first lessons (the "getting a
taste of OCaml" virtual section), but we are also looking for
contributions on advanced topics : we plan to make them start around
lesson 10, and focus on particular issues (modules, functors, labels,
objects, classes, polymorphic variants, etc.). Send us a mail if you
want to volunteer !

  As the engine is translated from OCaml to Javascript by js_of_ocaml,
you can even play with it offline, when you are disconnected.
      

Need help for a practical hacking book about ocaml

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

bobzhang announced:
   I was writing(or collecting)  a hacking book about ocaml, now it's
already more than 100 pages :-)
  I would help to contribute it for free to the ocaml comunity.  Anyone
would like
 to help it?
 I put it here  http://www.seas.upenn.edu/~hongboz/master.pdf

 My book mainly focus on how to make ocaml programmers more productive,
quite different from other existing books. Btw, I collected a lot online
resources, anyone can tell me how to credit them?

 I have been digging haskell, ocaml, lisp for several years, honestly
speaking, I found ocaml is still the most productive language.
      

RFC: basename, dirname, PR#4549

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

Damien Doligez asked:
I would like to get some comments from the OCaml community at large about
the problem raised in http://caml.inria.fr/mantis/view.php?id=4549

In a nutshell, the problem is that our version of basename and dirname
are not exactly the same as the Open Group's definition.

We can easily implement the standard behaviour for basename and dirname,
and it seems desirable, but there is a catch: we will have to change
the specification of the standard library slightly.

Currently, we specify this:

   [concat (dirname name) (basename name)] returns a file name
   which is equivalent to [name]. Moreover, after setting the
   current directory to [dirname name] (with {!Sys.chdir}),
   references to [basename name] (which is a relative file name)
   designate the same file as [name] before the call to {!Sys.chdir}.

With the Open Group basename and dirname, this becomes false for
names that include some trailing slashes, because such slashes
are removed by basename.  This means that a name "foo/bar/"
becomes "foo/bar" when put through
  [concat (dirname name) (basename name)]
and opening "foo/bar" may succeed if it is a file, while
opening "foo/bar/" would fail.

I would like to know if anyone relies on the precise behaviour
documented in the standard library, and for everyone else, would
you prefer the old behaviour or the new (standard) behaviour?
      

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/.

Beta-release of Coq 8.4:
  http://coq.inria.fr/beta-release-of-coq-84

Coq 8.3pl3 is out:
  http://coq.inria.fr/coq-83pl3-is-out

Announcing Baardskeerder:
  http://blog.incubaid.com/2011/12/23/announcing-baardskeerder/

Barista: 2.0-alpha2:
  https://forge.ocamlcore.org/forum/forum.php?forum_id=819

A Better (Gauss) Error Function:
  http://alaska-kamtchatka.blogspot.com/2011/12/better-gauss-error-function.html
      

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