Version française
Home     About     Download     Resources     Contact us    
Browse thread
Sexplib and types defined via constraint
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dario Teixeira <darioteixeira@y...>
Subject: Sexplib and types defined via constraint
Hi,

I've been using Sexplib quite extensively.  The syntax extension makes adding
(de)serialisation functions very simple and convenient, and up till now it
has automatically handled every data structure I threw at it.

But consider the module fragment below; type t is defined via a constraint,
and includes a type parameter ('b) used as a phantom type.  The Sexplib syntax
extension fails to parse the definition of t, producing an error:

Failure: "get_tparam_id: not a type parameter"
Preprocessing error on file document.ml

Is this a known limitation of Sexplib, in which case the (de)serialization
functions for t must be built manually?

Thanks in advance,
Dario Teixeira


module rec Foobar:
sig
        type foo_t = [ `A of int | `B of Foobar.bar_t ] with sexp
        type bar_t = [ `C of int | `D of Foobar.foo_t ] with sexp
        type foobar_t = [ foo_t | bar_t ] with sexp

        type (+'a, 'b) t = private Foobar of 'a constraint 'a = [< foobar_t ] with sexp
end =
struct
        type foo_t = [ `A of int | `B of Foobar.bar_t ] with sexp
        type bar_t = [ `C of int | `D of Foobar.foo_t ] with sexp
        type foobar_t = [ foo_t | bar_t ] with sexp

        type (+'a, 'b) t = Foobar of 'a constraint 'a = [< foobar_t ] with sexp
end



      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html