Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Pickling for OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] Pickling for OCaml?
> > Marshalling and "pickling" are synonyms. The Marshal module does not
> > provide runtime checks, yet, but the Caml team is working at it, as far as
> > I know.
>
> Myself and others at Cambridge, headed by Peter Sewell, are working on
> type- and abstraction-safe marshalling for O'Caml that works even where
> values to be marshalled are passed through polymorphic functions.
> Expect to hear more later this year.

Well, in the meantime, we've ported most of the pickling library from
SML.NET to work with O'Caml. Supports most of the basic types
(int,bool,char,string,list,array,unit,pairs->sextuples) and a few
combinators (alttag, wrap, lift,seq).

Fairly easy to define a pickler:

module BytePickle = Pickle.CorePickle(Pickle.ByteCodec)
open BytePickle

let pickler = pair (string list,int)

let data = pickle pickler (["hello";"world"],-1)

let value = unpickle pickler (List.rev data)

Files at http://devnulled.ath.cx/svn/dst/kernel/pickle.ml &
http://devnulled.ath.cx/svn/dst/kernel/pickle.mli

Kindest Regards,

Jonathan