English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Generation of Java code from OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-10-03 (12:16)
From: Anil Madhavapeddy <anil@r...>
Subject: Re: [Caml-list] Generation of Java code from OCaml
On 24 Sep 2009, at 13:19, Martin Jambon wrote:
> Oh yes, there's type-conv too.  I don't know the pros and cons of  
> using either
> type-conv or deriving.  If anyone knows, a brief comparison would be  
> helpful.

The nice thing about using type-conv is that syntax extensions can be  
composed quite easily, as long as the generators themselves don't  
depend too much on custom type syntax (e.g. when using sexplib, don't  
use the special sexp_option/sexp_opaque types).

I've ported your json-static extension over to type-conv so that we  
can use a combination of json/sexp and the (still in development) ORM  
extension side-by-side with a single type declaration, e.g.

type t = {
   foo: string;
   bar: int
} with orm (debug: all), json

... which generates both persistence functions and the json functions  
from the single type.  Right now it's fairly awkward to do this with  
json-static and the 'predefined' keyword as it requires duplicating  

The ported version of json-static to type-conv is available at:

The only thing I haven't quite worked out yet is the quotation to  
pattern-match type applications to detect things like "(string, unit)  
Hashtbl.t" the way the current json-static does via the grammar  
extension.  Most other types like char, int32/64, unit, poly variants,  
etc should all work.  There's a simple testcase in check_tc.ml in the  
same repository.