From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 6DA40BBAF for ; Sun, 22 Feb 2009 21:59:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQCACZLoUlDww+1mWdsb2JhbACUXAEBAQEBCAsKGLEMgQWNCQEEAgGCHIFwBg X-IronPort-AV: E=Sophos;i="4.38,251,1233529200"; d="scan'208";a="23348858" Received: from unknown (HELO web111509.mail.gq1.yahoo.com) ([67.195.15.181]) by mail3-smtp-sop.national.inria.fr with SMTP; 22 Feb 2009 21:59:18 +0100 Received: (qmail 6605 invoked by uid 60001); 22 Feb 2009 20:59:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1235336355; bh=ILrmcBeywlWrOQ4GeoTaWKizDX01SVEJYDJKFXxQNKI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=MO8eCkJ3JvAMPBPWxVFjgcC7yNsA271VfSzekChraQERFe/qd+HO4DZ6HGrQv8hd5zHCkgQiyL9SLqkPEh0QpNdfOzD3xsJiiyD/PIictdMk9M1yrtWglO8cObJ9UxntCLrpvbYgylEhLI57IgSyyFwshWKOuV/h3MglxTk+68g= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=vT7cHy37wayVqVUZl1Yh58pRjQOSvCkR/vnSFa4E5WiEeF0zDP2n5Ap/d6DHRU+LBULbKAXK+L5zmdqqXGHFHBic4ElTD9oHJ+xgQc37J2Hsx705g/qBFKUIxJObi5GX86Anqq+lbVAwk//4/ORV1/JhD72RSYrQDkafhMxadAU=; Message-ID: <168968.6250.qm@web111509.mail.gq1.yahoo.com> X-YMail-OSG: fONbWB4VM1lWdV161qIHmFMebvkc8W75tyQluw2oDiO3USzj9ckzEFB18sqDrgXD7IKLz4NvqBZ.AsDAPTluJ2EWm7WXp7o9G5THLnFB5uAobJ5sxXX5nRat7uLzaH40G__0845jSoz5t77vLQtlhNjcctGaNFKF.PylJ7ol.V514wktTU.Z4.P6WduLwR50TM3JPBP4hZX9HEdEql2vckXKvF2rxBHd6qifEwKN24tagX5PS_M5wSthAQjTvzmN2Q.UxTz__WCMT6ypQZPEzQ1hPlhMhOJ9zzYf63HoTnn1_TUh7v8VkQYTmGk2yxMx1fs56zuitOgfOzKa24_Mh76ZnS2kaB.OB0vvjvFH7lTUpcVn68g105SXE.LuWCGBcLBe4Inp.QMEsglAiAboJxq1WHNZDMKUN2P70nYB12Djun8- Received: from [213.205.71.58] by web111509.mail.gq1.yahoo.com via HTTP; Sun, 22 Feb 2009 12:59:14 PST X-Mailer: YahooMailWebService/0.7.289.1 Date: Sun, 22 Feb 2009 12:59:14 -0800 (PST) From: Dario Teixeira Subject: Unusual type declaration and Sexplib To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; foobar:01 sexp:01 syntax:01 sig:01 foobar:01 foo:01 sexp:01 val:01 foo:01 val:01 struct:01 recursive:01 annotations:01 coercions:01 859:98 Hi, I'm having some trouble serialising via Sexplib a data structure defined recursively. Consider module M defined below; note how type foobar_t inclu= des a "with sexp" declaration, telling the Sexplib syntax extension to create (de)serialisers automatically. However, type t cannot rely on that automat= ism, because type declarations with the "as" operator are not fully supported. Therefore, I need to create the (de)serialisers for this type manually. module M: sig type 'a foobar_t =3D [ `Foo of int | `Bar of 'a list ] with sexp type t =3D private [< 'a foobar_t ] as 'a val foo: int -> t val bar: t list -> t end =3D struct type 'a foobar_t =3D [ `Foo of int | `Bar of 'a list ] with sexp type t =3D 'a foobar_t as 'a let foo x =3D `Foo x let bar x =3D `Bar x end So basically the problem is creating the functions with the following signa= tures: val sexp_of_t: t -> Sexplib.Sexp.t val t_of_sexp: Sexplib.Sexp.t -> t Using as base the automatically created functions whose signatures are as f= ollows: val sexp_of_foobar_t: ('a -> Sexplib.Sexp.t) -> 'a foobar_t -> Sexplib.Sexp= .t val foobar_t_of_sexp: (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a foobar= _t But in practice, I'm having trouble seeing how these later functions can be used. The problem lies in their recursive definition: how would I break it? (And yes, I realise that the definition of type t is unusual, but it's extremely convenient for avoiding a lot of explicit annotations and coercions [1]). Thanks for your help! Best regards, Dario Teixeira [1] http://groups.google.com/group/fa.caml/browse_thread/thread/7552095ab85= 9fb5f/9c4a6fd19812fbcc =0A=0A=0A