[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-02-23 (10:32) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] Unusual type declaration and Sexplib |
From: Dario Teixeira <darioteixeira@yahoo.com> > I'm having some trouble serialising via Sexplib a data structure defined > recursively. Consider module M defined below; note how type foobar_t includes > a "with sexp" declaration, telling the Sexplib syntax extension to create > (de)serialisers automatically. However, type t cannot rely on that automatism, > because type declarations with the "as" operator are not fully supported. > Therefore, I need to create the (de)serialisers for this type manually. You program below is exactly equivalent to the following, without as. Or si your real code something different? module M: sig type 'a foobar_t = [ `Foo of int | `Bar of 'a list ] type t = private [< t foobar_t ] val foo: int -> t val bar: t list -> t end = struct type 'a foobar_t = [ `Foo of int | `Bar of 'a list ] type t = t foobar_t let foo x = `Foo x let bar x = `Bar x end Jacques Garrigue > module M: > sig > type 'a foobar_t = > [ `Foo of int > | `Bar of 'a list > ] with sexp > > type t = private [< 'a foobar_t ] as 'a > > val foo: int -> t > val bar: t list -> t > end = > struct > type 'a foobar_t = > [ `Foo of int > | `Bar of 'a list > ] with sexp > > type t = 'a foobar_t as 'a > > let foo x = `Foo x > let bar x = `Bar x > end