janestreet/sexplib

pa_sexp_conv and GADTs

trefis opened this issue · 5 comments

I installed Core (and sexplib) with opam a few days ago, and I am currently using the version 108.08 of sexplib, but pa_sexp_conv doesn't seem to have changed since 108.07 so the problem I have should still be present in the latest version.

The problem is the following :
# type foo = Foo : foo with sexp;; Error: Failure: "branch_sum: unknown type\nFoo : foo"

I don't know camlp4 at all, but from what I've seen I would guess that the error is raised at the line 387 of pa_sexp_conv.ml.
I don't know whether GADTs are not handled because they might make it impossible (in some cases involving existential types) to generate the usual functions (I haven't thought about it much), but even so they should be matched and a specific error should be raised.

And if they don't cause any problem then handling them would be great (ofc).

There is indeed an issue in the presence of existential types. I'll see what we can do about error messages.

Error messages have been updated.

So what's the progress on existential types?

With recent version of sexplib sexp_of_t produces Sexp.Atom "_" for existential types and t_of_sexp fails.

Well that makes sense! Thank you. This is a fantastic library.