Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] ANN: Sexplib - library for S-expression conversions

6 views
Skip to first unread message

Markus Mottl

unread,
Nov 7, 2005, 6:11:40 PM11/7/05
to ocaml, yaron jane
Hi,

we'd like to announce the availability of "Sexplib", which is a
library for handling S-expressions. It features a syntax extension
for OCaml using the Camlp4-preprocessor, which generates efficient
code derived from type definitions to convert OCaml-values to
S-expressions and vice versa. Errors during conversions are reported
fairly exactly and readably.

This syntax extension supports all extensional type constructions
(tuples/products, sum types, record types, variant types) together
with polymorphism. Other datatypes (objects; abstract ones) require
user-defined converters, which can be added very easily.

The parsing and pretty-printing functions for S-expressions together
with the automatically generated converters make this library very
useful for a variety of purposes, e.g. for representing datastructures
in human-readable form, for debugging, etc. We are using it for
handling fairly large and complex software configurations, and have
found this representation and functionality extremely helpful in
practice.

The Sexplib-library itself was initially derived from Martin Sandin's
Tywith-library, and is available free of charge under the
LGPL-license. You can download it from the following site:

http://www.janestcapital.com/ocaml

We, the Quant-group at Jane St. Capital, are in the process of setting
up this site to publish free software developed at our company. We
hope you will find a lot more useful libraries there in the near
future.

Best regards,
Markus Mottl for the Quant Group at Jane St. Capital

--
Markus Mottl http://www.ocaml.info markus...@gmail.com

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Florian Hars

unread,
Nov 8, 2005, 10:50:16 AM11/8/05
to Markus Mottl, yaron jane, ocaml
Markus Mottl wrote:
> is available free of charge under the LGPL-license.

Just to make sure this isn't an accidental oversight: you know that the LGPL is
almost always the wrong license for ocaml code (since it is almost
indistinguishable from GPL due to the way the ocaml linker works) and made
a conscious decision to use it nonetheless?

Yours, Florian.
--
#!/bin/sh -
set - `type -p $0` 'tr [a-m][n-z]RUXJAKBOZ [n-z][a-m]EH$W/@OBM' fu XUBZRA.fvt\
angher echo;while [ "$5" != "" ];do shift;done;$4 "gbhpu $3;znvy sKunef.qr<$3\
&&frq -a -rc "`$4 "$0"|$1`">$3;rpub 'Jr ner Svtangher bs Obet.'"|$1|`$4 $2|$1`

N. Owen Gunden

unread,
Nov 8, 2005, 11:06:39 AM11/8/05
to caml...@yquem.inria.fr, ocaml
On Mon, Nov 07, 2005 at 06:09:34PM -0500, Markus Mottl wrote:
> we'd like to announce the availability of "Sexplib" [...]

And here are some simple usage examples:

----------------
# open Sexplib;;

# type t = { foo : int; bar : string; } with sexp;;
type t = { foo : int; bar : string; }
val sexp_of_t : t -> Sexplib.Sexp.t = <fun>
val t_of_sexp : Sexplib.Sexp.t -> t = <fun>

# let v = { foo = 3; bar = "baz"; };;
val v : t = {foo = 3; bar = "baz"}

# sexp_of_t v;;
- : Sexplib.Sexp.t = ((foo 3) (bar baz))

# t_of_sexp (Sexp.of_string "((foo 31337) (bar \"quux\"))");;
- : t = {foo = 31337; bar = "quux"}
----------------

You can also just get a converter for a specific direction, not both:

----------------
# type foo = A | B with sexp_of;;
type foo = A | B
val sexp_of_foo : foo -> Sexplib.Sexp.t = <fun>

# type foo = A | B with of_sexp;;
type foo = A | B
val foo_of_sexp : Sexplib.Sexp.t -> foo = <fun>
----------------

A more complicated example, building a bigger type out of the same t we
used above:

----------------
# type t' = t * [`foo|`bar] with sexp_of;;
type t' = t * [ `bar | `foo ]
val sexp_of_t' : t * [< `bar | `foo ] -> Sexplib.Sexp.t = <fun>

# sexp_of_t' (v, `foo);;
- : Sexplib.Sexp.t = (((foo 3) (bar baz)) foo)
----------------

I can also manually define the converter for a type that's contained
within, and the converter for the larger type will use mine:

----------------
# let sexp_of_t t = Sexp.Atom (Printf.sprintf "<t with foo=%d and bar=%S>" t.foo t.bar);;
val sexp_of_t : t -> Sexplib.Sexp.t = <fun>

# type t' = t * [`foo|`bar] with sexp_of;;
type t' = t * [ `bar | `foo ]

val sexp_of_t' : t * [< `bar | `foo ] -> Sexplib.Sexp.t = <fun>
# sexp_of_t' (v, `foo);;
- : Sexplib.Sexp.t = ("<t with foo=3 and bar=\"baz\">" foo)
----------------

- O

Markus Mottl

unread,
Nov 8, 2005, 1:31:33 PM11/8/05
to Florian Hars, yaron jane, ocaml
On 11/8/05, Florian Hars <flo...@hars.de> wrote:
> Markus Mottl wrote:
> > is available free of charge under the LGPL-license.
>
> Just to make sure this isn't an accidental oversight: you know that the L
GPL is
> almost always the wrong license for ocaml code (since it is almost
> indistinguishable from GPL due to the way the ocaml linker works) and mad
e
> a conscious decision to use it nonetheless?

Sorry for the confusion, but I should have mentioned in my
announcement that it is available under the LGPL including the special
exception also employed by INRIA to work around the linking
restrictions. In case you have downloaded the library, you may have
seen that it was already distributed that way. Thus you don't have
any excuse now for not using the library ;-)

Regards,
Markus

_______________________________________________

N. Owen Gunden

unread,
Nov 8, 2005, 9:11:55 PM11/8/05
to caml...@yquem.inria.fr
On Mon, Nov 07, 2005 at 06:09:34PM -0500, Markus Mottl wrote:
> we'd like to announce the availability of "Sexplib"

There is now a godi package: godi-sexplib

skaller

unread,
Nov 9, 2005, 3:49:16 AM11/9/05
to Markus Mottl, yaron jane, Florian Hars, ocaml
On Tue, 2005-11-08 at 13:29 -0500, Markus Mottl wrote:

> Sorry for the confusion, but I should have mentioned in my
> announcement that it is available under the LGPL including the special
> exception also employed by INRIA to work around the linking
> restrictions.


I use the acronym

LGPLX

for that licence.

> In case you have downloaded the library, you may have
> seen that it was already distributed that way. Thus you don't have
> any excuse now for not using the library ;-)

Unless you're redistributing source code under a less restrictive
licence eg BSD, MIT, etc ;(

--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

Sven Luther

unread,
Nov 9, 2005, 4:07:34 AM11/9/05
to skaller, Markus Mottl, yaron jane, Florian Hars, ocaml
On Wed, Nov 09, 2005 at 07:42:19PM +1100, skaller wrote:
> On Tue, 2005-11-08 at 13:29 -0500, Markus Mottl wrote:
>
> > Sorry for the confusion, but I should have mentioned in my
> > announcement that it is available under the LGPL including the special
> > exception also employed by INRIA to work around the linking
> > restrictions.
>
>
> I use the acronym
>
> LGPLX
>
> for that licence.

What about LGPL-OCAML ?

Friendly,

Sven Luther

skaller

unread,
Nov 9, 2005, 4:29:45 AM11/9/05
to Sven Luther, Markus Mottl, yaron jane, Florian Hars, ocaml
On Wed, 2005-11-09 at 09:57 +0100, Sven Luther wrote:
> On Wed, Nov 09, 2005 at 07:42:19PM +1100, skaller wrote:
> > On Tue, 2005-11-08 at 13:29 -0500, Markus Mottl wrote:
> >
> > > Sorry for the confusion, but I should have mentioned in my
> > > announcement that it is available under the LGPL including the special
> > > exception also employed by INRIA to work around the linking
> > > restrictions.
> >
> >
> > I use the acronym
> >
> > LGPLX
> >
> > for that licence.
>
> What about LGPL-OCAML ?

Fine by me, though I note that LGPL with linking exemption
need not be restricted to Ocaml: if others adopted this,
for example for C packages, the OCAML would be a misnomer.
OTOH LGPL-OCAML is more suggestive in the case of Ocaml
codes.

BTW: for Debian GPL and LGPL licences do not have to
be provided in full, since they're installed automatically
in /usr/share somewhere. It would be nice if LGPLX/LGPL-OCAML
was treated the same way.

Although GODI cannot do it yet, eventually it would be nice
to be able to constrain and/or report licences when building
packages -- which requires a licencing system with centralised
licences with recognized keys and behaviour rules.

Maybe INRIA, Gerd and Sven can get together and agree on
an acronym, and also get the licence certified by OSS?

IMHO this licence is a pretty good compromise: it prevents
'closed source' being distributed fully closed, but it doesn't
prevent closed source being used to generate closed binaries,
nor does it prevent closed source being distributed along
with open source (provided that open source remains open).

AFAICS it only 'infects' sources if one derives from
a combination of the open and closed source, then the
closed sources must be opened.

--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

_______________________________________________

0 new messages